Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $data=array("user1"=>array("url"=>"page1.php","password"=>"12345"),
  5. "user2"=>array("url"=>"page2.php","password"=>"12345"),
  6. "user3"=>array("url"=>"page3.php","password"=>"12345")
  7. );
  8.  
  9. if(isset($_POST['username']) && isset($_POST['password'])) {
  10.  
  11. $user = strtolower($_POST['username']);
  12. $pass = strtolower($_POST['password']);
  13.  
  14. if($data[$user]['password'] == $pass) {
  15. $_SESSION['username'] = $user . " " . $pass;
  16. header('Location: ' . $data[$user]['url']);
  17. } else {
  18. echo '<script type="text/javascript">window.onload = function() { document.getElementById("loginError").innerHTML = "' . "Invalid login details. Please try again." . '"; }</script>';
  19. logIn();
  20. }
  21. } else {
  22. logIn();
  23. }
  24. ?>
  25.  
  26. if(isset($_POST['username']) && !empty($_POST['username']) &&
  27. isset($_POST['password']) && !empty($_POST['password']) ) {
  28. //Do code here
  29. }
  30. else
  31. {
  32. logIn();
  33. }
  34.  
  35. ...
  36. $user = strtolower(trim($_POST['username']));
  37. $pass = strtolower(trim($_POST['password']));
  38.  
  39. if($user !== '' && $pass !== '') {
  40. //continue with login logic
  41. if($data[$user]['password'] === $pass) {
  42. ...
  43. }
  44. else{
  45. //print error
  46. }
  47.  
  48. session_start();
  49.  
  50. $data=array("user1"=>array("url"=>"page1.php","password"=>"12345"),
  51. "user2"=>array("url"=>"page2.php","password"=>"12345"),
  52. "user3"=>array("url"=>"page3.php","password"=>"12345")
  53. );
  54.  
  55. if (!empty($_POST['username'] && !empty($_POST['password'])) {
  56.  
  57. $user = strtolower($_POST['username']);
  58. $pass = strtolower($_POST['password']);
  59.  
  60. if (isset($data[$user]) && $data[user]['password'] == $pass) {
  61. $_SESSION['username'] = $user . ' ' . $pass;
  62. header("Location: " . $daa[$user]['url']);
  63. } else {
  64. echo '<script type="text/javascript">window.onload = function() { document.getElementById("loginError").innerHTML = "' . "Invalid login details. Please try again." . '"; }</script>';
  65. logIn();
  66. }
  67.  
  68. } else {
  69. logIn();
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement