Guest User

Untitled

a guest
Mar 24th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5.  
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8.  
  9. if($username&&$password)
  10. {
  11.  
  12. $connect = mysql_connect("localhost","root","") or die("Could not connect");
  13. mysql_select_db("phplogin") or die("Could not find db");
  14.  
  15. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  16.  
  17. $numrows = mysql_num_rows($query);
  18.  
  19. if ($numrows!=0)
  20. {
  21.  
  22. while ($row = mysql_fetch_assoc($query))
  23. {
  24.         $dbusername = $row ['username'];
  25.         $dbpassword = $row ['password'];
  26.        
  27. }
  28.  
  29. if ($username==$dbusername&&$password==$dbpassword)
  30. {
  31.     echo "You are in! <a href='index2.php'>click</a< here to enter the member page.";
  32.     $_session['username']=$username;
  33.    
  34.    
  35. }
  36.  
  37. else
  38.     echo "Incorrect password!";
  39. }
  40.  
  41. else
  42.     die("That user does not exist!");
  43.  
  44. }
  45. else
  46.     die("Please enter a username and password!");
  47.  
  48. ?>
Add Comment
Please, Sign In to add comment