Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. $server="localhost";
  3. $username="root";
  4. $password="admin007#";
  5. $dbname="demo";
  6.  
  7. $con=new mysqli($server,$username,$password,$dbname);
  8. if(!$con)
  9. {
  10. die('error connecting to the database');
  11. }
  12.  
  13.  
  14. if(isset($_POST['login'])){
  15. $a=mysqli_real_escape_string($con, $_POST['user']);
  16. $b=mysqli_real_escape_string($con, $_POST['pass']);
  17. $sql="SELECT * FROM login WHERE username='$a' AND password='$b'";
  18. $result=mysqli_query($con, $sql);
  19. $check=mysqli_num_rows($result);
  20. if($check>0){
  21. echo "you are logged in";
  22. }
  23. else
  24. {
  25. echo "Error";
  26. }
  27. }
  28.  
  29. ?>
  30. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  31. <html xmlns="http://www.w3.org/1999/xhtml">
  32. <head>
  33. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  34. <title>Untitled Document</title>
  35. </head>
  36.  
  37. <body>
  38. <tr>
  39. <td>Username:</td>
  40. <td><input type="text" name="user" value=""/></td>
  41. </tr><br /><br />
  42. <tr>
  43. Password:
  44. <td><input type="password" name="pass" value=""/></td>
  45. </tr><br />
  46. <tr align="center"><td colspan="2"><input type="submit" name="login" value="Log In"/></td></tr>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement