This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 24th, 2012  |  syntax: PHP  |  size: 0.84 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. ?>
clone this paste RAW Paste Data