Guest User

Untitled

a guest
Jun 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. include 'config.php';
  5.  
  6. if (isset($_GET['logged']))
  7. {
  8. $username = htmlspecialchars($_POST['username']);
  9. $password = htmlspecialchars($_POST['password']);
  10.  
  11. $check = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'")
  12. or die(mysql_error());
  13.  
  14. $data = mysql_fetch_array($check);
  15.  
  16. if (mysql_num_rows($check) == '0')
  17. {
  18. echo "Don't try that one sonny";
  19. }
  20.  
  21. else
  22. {
  23. if ($data['password'] == $password)
  24. {
  25. $fetchd = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'")
  26. or die(mysql_error());
  27.  
  28. $fetchu = mysql_fetch_array($fetchd);
  29.  
  30. $_SESSION['id'] = "$user[id]";
  31. $_SESSION['password'] = "$user[password]";
  32.  
  33. echo "You are now logged in";
  34. echo "<meta http-equiv='refresh' content='2; URL=index.php'";
  35. }
  36. }
  37. }
  38.  
  39. else
  40. {
  41. echo "
  42. <form method='post' action='login.php?logged' />
  43. Username:<br />
  44. <input type='text' name='username' /><br />
  45.  
  46. Password:<br />
  47. <input type='password' name='password' /><br />
  48.  
  49. <input type='submit' name='submit' value='Submit' />
  50. </form>
  51. ";
  52. }
  53.  
  54. ?>
Add Comment
Please, Sign In to add comment