I am creating a login page and am having trouble with the cookie and redirect function.
Basically I want the user to have a simple textbox, if they type in the correct password they get directed to the admin page and a cookie is set for all other admin pages to check.
Can someone see where I am going wrong?
I
Basically I want the user to have a simple textbox, if they type in the correct password they get directed to the admin page and a cookie is set for all other admin pages to check.
Can someone see where I am going wrong?
Code:
<?php
if (isset($_COOKIE["ValidUser"])) {
header( 'Location: admin.php' ) ;
}
//first look to see if they have logged in with coreect pass, if yes then set cookie
if ($_POST["loginpass"] = "reflect") {
setcookie("ValidUser", "Validated", time()+3600);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<title>foo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Administration area</h1>
Enter your password to log in
<form action='index.php' method='post'>
<input type='password' name='loginpass' />
<input type='submit' value='log in' />
</form>
</body>
</html>
I