login script using cookies - cant find my id10t errors
Posted: Fri Aug 01, 2003 4:57 am
I'm trying to write a login script using cookies, and a database i've looked a quite a few of the tutorial login scripts on the net and cant seem to find what I am looking for. I pretty much know what I want and am pretty sure i'm doing it correctly, but its still giving me no result.
If you could point out where i've gone wrong it would be cool.
Thanks,
Thanks,
Code: Select all
<?
require("mysql.php");
if ($action == "login") {
$query = "SELECT password FROM users WHERE username='$username'";
$results = mysql_query($query);
while ($rows=mysql_fetch_assoc($results))
{ //open of mysql password retrieveal
//$encryptedpassword = md5($password);
//sets the password to encrypted version so it match the db password
if ($password === $rows['password']){ //start if password
setcookie("admin", "loggedin", "3600");
header('Location: admin.php');
}//end if password
else { //start else
$error = "incorrect password";
} //finish else
} //close of password retrieveal mysql
}//close of login.
elseif ($action == "logout") {
setcookie("admin", "loggedout", "-3600");
header('Location: http://www.google.com');
}
echo $error;
?>
<?
if ($admin == "loggedin") {
?>
your logged in!!
<?
}
?>