Jump to content

mrmcg

New Members
  • Posts

    1
  • Joined

  • Last visited

mrmcg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.