Guest User

Untitled

a guest
Sep 18th, 2018
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. ex. html
  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. <p>&nbsp;</p>
  11. <form action="loginform.php" method="post">
  12. User Name:<input type="text" name="username" /><br /><p>
  13. Password:<input type="password" name="password" /><br /><p>
  14. <input type="submit" name="submit" value="Login" />
  15. </form>
  16. </body>
  17. </html>
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. loginform.php
  29. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  30. <html xmlns="http://www.w3.org/1999/xhtml">
  31. <head>
  32. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  33. <title>Untitled Document</title>
  34. </head>
  35.  
  36. <body>
  37. <?php
  38. session_start();
  39. $username=$_POST['username'];
  40. $password=$_POST['password'];
  41.  
  42. if ($username&&$password)
  43. {
  44. $connect = mysql_connect("localhost","root"," ");
  45. if(!$connect)
  46. { die("couldn't find database"); }
  47. mysql_select_db("sample");
  48. $query = mysql_query("select * from login where username='$username'");
  49. $numrows = mysql_num_rows($query);
  50.  
  51. if($numrows!=0)
  52. {
  53. while($row = mysql_fetch_assoc($query))
  54. {
  55. $dbusername = $row['username'];
  56. $dbpassword = $row['password'];
  57.  
  58. }
  59. if($username==$dbusername&&$password==$dbpassword)
  60. {
  61. echo 'Login successful';
  62. $_SESSION['username']= $dbusername;
  63. }
  64. else
  65. echo 'Incorrect Password';
  66. } //end of numows
  67. else
  68. die("That username doesnt exist");
  69. } // end of first if
  70. else
  71. die("Please enter username and password");
  72. mysql_close($connect);
  73. ?>
  74. </body>
  75. </html>
Add Comment
Please, Sign In to add comment