Advertisement
Guest User

Untitled

a guest
Mar 8th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php echo $error; ?>
  2. <form method="post" action="login.php">
  3. Username: <input type="text" name="username"> <br>
  4. Password: <input type="password" name="password"> <br>
  5. <input type="submit" value="Log In">
  6. </form>
  7.  
  8. <?php
  9. function pc_validate($user,$pass) {
  10. /* replace with appropriate username and password checking,
  11. such as checking a database */
  12. $users = array('admin' => '1234567');
  13.  
  14. if (isset($users[$user]) && ($users[$user] == $pass)) {
  15. return true;
  16. } else {
  17. return false;
  18. }
  19. }
  20.  
  21. $secret_word = 'if i ate spinach';
  22. if (pc_validate($_REQUEST['username'],$_REQUEST['password'])) {
  23. setcookie('login',
  24.  
  25. $_REQUEST['username'].','.md5($_REQUEST['username'].$secret_word));
  26.  
  27. header('Location: site/index.php');
  28. }
  29.  
  30. ?>
  31.  
  32. <?php
  33.  
  34. $secret_word = 'if i ate spinach';
  35. if (isset($_COOKIE['login'])) {
  36. list($c_username,$cookie_hash) = explode(',',$_COOKIE['login']);
  37. if (md5($c_username.$secret_word) == $cookie_hash) {
  38. $username = $c_username;
  39. } else {
  40. header('Location: extra/index.php');
  41. }
  42. } else {
  43. header('Location: extra/index.php');
  44.  
  45. }
  46.  
  47. ?>
  48.  
  49. <?php
  50. include('session.php');
  51.  
  52. ?>
  53. Hey Welcome! <?php echo $username; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement