Guest User

Untitled

a guest
Dec 13th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <?php
  2. $con = mysql_connect("localhost","root","");
  3. if (!$con)
  4. {
  5. die('Could not connect: ' . mysql_error());
  6. }
  7.  
  8. mysql_select_db("users", $con) or die("Can't select db.");
  9.  
  10.  
  11. if (isset($_POST['username']) && isset($_POST['password')) {
  12.  
  13. if (($_POST['username'] == $user) && ($_POST['password'] == $pass)) {
  14.  
  15. if (isset($_POST['rememberme'])) {
  16. /* Set cookie to last 1 year */
  17. setcookie('username', $_POST['username'], time()+60*60*24*365
  18. setcookie('password', md5($_POST['password']), time()+60*60*24*365
  19.  
  20. } else {
  21. /* Cookie expires when browser closes */
  22. setcookie('username', $_POST['username'], false
  23. setcookie('password', md5($_POST['password']), false
  24. }
  25. header('Location: login.php');
  26.  
  27. } else {
  28. echo 'Username/Password Invalid';
  29. }
  30.  
  31. } else {
  32. echo 'You must supply a username and password.';
  33. }
  34.  
  35. ?>
  36.  
  37.  
  38. <!DOCTYPE html>
  39. <html>
  40. <body>
  41.  
  42. <form action="login.php" method="POST">
  43. Username: <input type="text" name="username"><br>
  44. Password: <input type="password" name="password"><br />
  45. <input type="submit" value="Login."></form> <br />
  46.  
  47.  
  48.  
  49. </body>
  50. </html>
Add Comment
Please, Sign In to add comment