Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @author Jason
  5. * @copyright 2010
  6. */
  7.  
  8. session_start();
  9.  
  10. $username = addslashes( $_POST['username'] );
  11. $password = addslashes( $_POST['password'] );
  12.  
  13. if ( isset( $_POST['submit'] ) )
  14. {
  15.  
  16. if ( $username && $password )
  17. {
  18.  
  19. $connect = mysql_connect( "localhost", "root", "jason" ) or die( "Cannot connect to database!" );
  20. mysql_select_db( "usersystem" ) or die( "Cannot connect to database!" );
  21.  
  22. $query = mysql_query( "SELECT * FROM `users` WHERE `username` = '$username'" );
  23.  
  24. $numrows = mysql_num_rows( $query );
  25.  
  26. if ( $numrows )
  27. {
  28.  
  29. while ( $r = mysql_fetch_assoc( $query ) )
  30. {
  31.  
  32. $dbusername = $r['username'];
  33. $dbpassword = $r['password'];
  34.  
  35. }
  36.  
  37. if ( $username == $dbusername && $password == $dbpassword )
  38. {
  39.  
  40. if( isset( $_SESSION['username'] ) && isset( $_SESSION['password'] ) ){
  41.  
  42. echo 'only logged people can seee!';
  43. }
  44. else
  45. {
  46. ?>
  47. <html>
  48.  
  49. <form method='post' action="">
  50.  
  51. Username: <input type="text" name="username"/><br />
  52. Password: <input type="password" name="password"/><br />
  53.  
  54. <input type="submit" value="Log in" name="submit" />
  55.  
  56. </form>
  57.  
  58. </html>
  59. <?php
  60.  
  61. }
  62.  
  63. }
  64. else
  65. {
  66. echo "Incorrect Password";
  67.  
  68. }
  69.  
  70. }
  71. else
  72. {
  73.  
  74. echo "Username doesn't exist!";
  75.  
  76. }
  77.  
  78. }
  79. else
  80. {
  81.  
  82. echo "Please enter a username and password.";
  83.  
  84. }
  85.  
  86. }
  87.  
  88. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement