I'm trying to set up a VERY simple, and not very secures 1 user system using cookies, I made this.... it can be found at http://macboy.maclevel.com/login.php user: test, pass: test_password
the login works, but the cookies don't.
any help would be appreciated.
this is the code:
the login works, but the cookies don't.
any help would be appreciated.
this is the code:
PHP:
<html><head><title>Welcome!</title></head><body>
<?php
// Define username and password
$username = "test";
$password = "test_password";
if (isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
echo ( 'Welcome' . $username . '!' );
}
else{
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<h1>Login</h1>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
****<p><label for="txtUsername">Username:</label>
****<br /><input type="text" title="Enter your Username" name="txtUsername" /></p>
****<p><label for="txtpassword">Password:</label>
****<br /><input type="password" title="Enter your password" name="txtPassword" /></p>
****<p><input type="submit" name="Submit" value="Login" /></p>
</form>
<?php
}
else {
setcookie ('username' , $username, time()+3600);
setcookie ('password' , $password, time()+3600);
?>
Login Successful! <br /> <a href="<?php echo( $_SERVER['PHP_SELF'] ); ?>" >Continue</a>
<?php
}
}
?>