Guest User

Untitled

a guest
Mar 13th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4.  
  5.   // connect to the mysql database
  6.   $con = mysql_connect("127.0.0.1","root","seedubuntu");
  7.   mysql_select_db("test_cms", $con);
  8.  
  9.   // get the user data
  10.   $username = $_POST['user'];
  11.   $password = $_POST['password'];
  12.  
  13.   // query the database
  14.   $sql = "SELECT * FROM cms_users WHERE username = '".$username."' AND password = '".$password."'";  
  15.   $result = mysql_query($sql);
  16.   $number_of_results = mysql_num_rows($result);
  17.  
  18.   if ($number_of_results == 0)
  19.   {
  20.       print "Wrong username/password <br>";
  21.   }
  22.   else
  23.   {
  24.     $row = mysql_fetch_array($result);
  25.     print "Welcome ".$row['username']."! You are logged in.<br>";
  26.   }
  27.   // close the connection to the database
  28.   mysql_close($con);
  29. ?>
  30. </body>
  31. </html>
Add Comment
Please, Sign In to add comment