<?php
 session_start();
 include('../config/connection.php');
 $username=$_POST['username'];
 $password=$_POST['password'];
 $sql=mysql_query("SELECT * FROM user WHERE username='$username' AND password='$password'");
 $count=mysql_num_rows($sql);
 $rows=mysql_fetch_array($sql);
 if($count==0)
 {
  header('location:../index.php');	 
 }
 else
 {
	 $_SESSION['post']=$rows['post'];
	 $_SESSION['userid']=$rows['id'];
	 $_SESSION['name']=$rows['name'];
	 $_SESSION['consult']=$rows['consult_porson'];
	 $sql_update=mysql_query("UPDATE `user` SET `last_visit`=NOW() WHERE username='$username' AND password='$password'");
	 header('location:../home.php');
 }
?>