Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <html>
  2. <head>
  3. <body bgcolor="">
  4. <font>
  5. <center><h1>Login</h1></center>
  6. </font>
  7. <form action="login.php" method="POST">
  8. Username:<input type="text" name="uname">
  9. Password:<input type="password" name="pass"><br>
  10. <input type="submit" value="login" name="submit">
  11. </form>
  12. </body>
  13. </head>
  14. </html>
  15.  
  16. <?php
  17. require ('sql_connect.php');
  18. if (isset($_POST['submit'])){
  19. $username=mysql_escape_string($_POST['uname']);
  20. $password=mysql_escape_string($_POST['pass']);
  21. if (!$_POST['uname'] | !$_POST['pass'])
  22.  {
  23. echo ("<SCRIPT LANGUAGE='JavaScript'>
  24.        window.alert('You did not complete all of the required fields')
  25.        window.location.href='htmlogin.html'
  26.        </SCRIPT>");
  27. exit();
  28.      }
  29. $sql= mysql_query("SELECT * FROM `login_users` WHERE `username` = '$username' AND `password` = '$password'");
  30. if(mysql_num_rows($sql) > 0)
  31. {
  32. echo ("<SCRIPT LANGUAGE='JavaScript'>
  33.        window.alert('Login Succesfully!.')
  34.        window.location.href='congratz.html'
  35.        </SCRIPT>");
  36. exit();
  37. }
  38. else{
  39. echo ("<SCRIPT LANGUAGE='JavaScript'>
  40.        window.alert('Wrong username password combination.Please re-enter.')
  41.        window.location.href='htmllogin.html'
  42.        </SCRIPT>");
  43. exit();
  44. }
  45. }
  46. else{
  47. }
  48. ?>
  49.  
  50.  
  51. <?php
  52. mysql_connect("localhost", "root", "") or die("mysql connection is failure.");
  53. mysql_select_db("login") or die("Database does not exists.");
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement