Guest User

Untitled

a guest
Sep 18th, 2018
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. loginform.php
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <title>Untitled Document</title>
  7. </head>
  8.  
  9. <body>
  10. <?php
  11. session_start();
  12. $username=$_POST['username'];
  13. $password=$_POST['password'];
  14.  
  15. if ($username&&$password)
  16. {
  17. $connect = mysql_connect("localhost","root","");
  18. if(!$connect)
  19. { die("couldn't find database"); }
  20. mysql_select_db("sample");
  21. $query = mysql_query("select * from login where username='$username'");
  22. $numrows = mysql_num_rows($query);
  23.  
  24. if($numrows!=0)
  25. {
  26. while($row = mysql_fetch_assoc($query))
  27. {
  28. $dbusername = $row['username'];
  29. $dbpassword = $row['password'];
  30.  
  31. }
  32. if($username==$dbusername&&$password==$dbpassword)
  33. {
  34. echo 'Login successful';
  35. $_SESSION['username']= $dbusername;
  36. }
  37. else
  38. echo 'Incorrect Password';
  39. } //end of numows
  40. else
  41. die("That username doesnt exist");
  42. } // end of first if
  43. else
  44. die("Please enter username and password");
  45. mysql_close($connect);
  46. ?>
  47. </body>
  48. </html>
Add Comment
Please, Sign In to add comment