Hi
Im really new to php and have been having a big headache from this latest problem im facing.
All I want to do is save the username to a cookie on one page then access that cookie in the next few pages to insert the username into mysql through a form.
Have a look at the code i have so far..................It seems so simple.............. It just won't save the cookie to my computer
logger.php
<?php
/* These are our valid username and passwords */
$user = 'jonny4';
$pass = 'delafoo';
if (isset($_POST['username'])) {
if ($_POST['username'] == $user) {
if (isset($_POST['rememberme'])) {
/* Set cookie to last 1 year */
setcookie('username', $_POST['username'], time()+60*60, '/', 'www.kelly.com');
} else {
/* Cookie expires when browser closes */
setcookie('username', $_POST['username'], false, '/', 'www.kelly.com');
}
header('Location: form/form.html');
} else {
echo 'Username/Password Invalid';
}
} else {
echo 'You must supply a username and password.';
}
?>
Index.html
<p>
<h2>User Login </h2>
<form name="login" method="post" action="logger.php">
Username: <input type="text" name="username">
<input type="checkbox" name="rememberme" value="1" checked="yes" hidden><br>
<input type="submit" name="submit" value="Login!">
</form>
</p>
Any help with this would be greatly appreciated as its hurting my head now.
Lets see if a lie down will help
Thanks in advance