Hello , I read that Cookies are good way to transfer info between pages , So I wrote my own login script , but when I move to then next page it can't read the cookie that I made in the login php page !!
<?phpfunction CheckLoginInDB($username,$password){ $con=mysql_connect('localhost','root','123'); mysql_select_db('users', $con); if(!$con) { echo "Database login failed! PLease try again"; return false; } $qry = "Select * from users.usrinfo where usrlogin='$username' and usrpass='$password' "; $result = mysql_query($qry); $count = mysql_num_rows($result); if( $count!=1 ) { echo "Error logging in. " ."The username or password does not match"; return false; } return true;} if(empty($_POST['username'])) { echo "UserName is empty!<br />"; } if(empty($_POST['password'])) { echo "Password is empty!"; return false; } $username = trim($_POST['username']); $password = trim($_POST['password']); if(!CheckLoginInDB($username,$password)) { echo "Wrong Password !!"; } else { $cookieusr =$_POST['username']; setcookie("user",$cookieusr,time()+36000); echo "You Have logged in succesfully !!"; } ?>