Guest User

Untitled

a guest
Dec 10th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title> Log-in </title>
  4. </head>
  5. <body>
  6.  
  7. <form action="login.php" method="POST">
  8. Username: <input type="text" name=username">
  9. Password: <input type="password" name="password">
  10. <input type="submit" name="login" value="Login">
  11. </form>
  12.  
  13. <?php
  14.  
  15. if(isset($_POST['username']) && isset($_POST['login'])){
  16. $un = $_POST['username'];
  17. }
  18.  
  19. if(isset($_POST['password']) && isset($_POST['login'])){
  20. $pass = $_POST['password'];
  21. }
  22.  
  23. $db = mysql_connect("127.0.0.1:3306", "root" , "Iaml33+lol");
  24.  
  25. if(!$db) {
  26. die("Error connecting to database: " . mysql_error());
  27. }
  28.  
  29. $db_used = mysql_select_db("login", $db);
  30.  
  31. if(!$db_used){
  32. die("Could not select database: " . mysql_error());
  33. }
  34.  
  35. $user_name = mysql_real_escape_string($un);
  36. $password = mysql_real_escape_string($pass);
  37.  
  38. $query = "SELECT * FROM details WHERE un='$user_name' AND pwd='$password'";
  39.  
  40. $check = mysql_query($query);
  41.  
  42. $check_rows = mysql_num_rows($check);
  43.  
  44. if(isset($_POST['login']) && $check_rows == 1){
  45. echo "Login was successful, redirecting now";
  46. }
  47. else{
  48. echo "Login failed, please ensure you use the right username and password";
  49. }
  50.  
  51. ?>
  52.  
  53. </body>
  54. </html>
Add Comment
Please, Sign In to add comment