Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <form action="http://www.mySite.co/login.php" method="post">
  2. <fieldset>
  3. <p><input type="text" name="uname" placeholder="Name" required></p>
  4. <p><input type="password" name="pass" placeholder="identity number" required></p>
  5. <p><a href="#">Forgot Password?</a></p>
  6. <p><input type="submit" name="submit" value="Login"></p>
  7. </fieldset>
  8. </form>
  9.  
  10. <?php
  11.  
  12. $mydb = new wpdb('DB UserName','DB Password','DB','localhost');
  13.  
  14.  
  15. if (isset($_POST['submit'])){
  16. $username=mysql_escape_string($_POST['uname']);
  17. $password=mysql_escape_string($_POST['pass']);
  18. if (!$_POST['uname'] | !$_POST['pass'])
  19. {
  20. echo ("<SCRIPT LANGUAGE='JavaScript'>
  21. window.alert('You did not complete all of the required fields')
  22. window.location.href='htmlogin.html'
  23. </SCRIPT>");
  24. exit();
  25. }
  26. $sql=$mydb->get_results("SELECT * FROM `TableName` WHERE `NAME` = '$username' AND `ID` = '$password'");
  27.  
  28. if($mydb->num_rows($sql) > 0)
  29. {
  30. echo ("<SCRIPT LANGUAGE='JavaScript'>
  31. window.alert('Login Succesfully!.')
  32. window.location.href='htmllogin.html'
  33. </SCRIPT>");
  34. exit();
  35. }
  36. else{
  37. echo ("<SCRIPT LANGUAGE='JavaScript'>
  38. window.alert('Wrong username password combination.Please re-enter.')
  39. window.location.href='htmllogin.html'
  40. </SCRIPT>");
  41. exit();
  42. }
  43. }
  44. else{
  45. }
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement