Advertisement
Guest User

Untitled

a guest
Apr 9th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. <?php
  2. //setting variables for connecting to database
  3. $host = 'localhost';
  4. $username = 'root';
  5. $password = '';
  6. $db = 'aquamandb';
  7. date_default_timezone_set('America/Chicago');
  8.  
  9. //connecting to the database
  10. $connect = new mysqli($host,$username, $password, $db) or die("Unable to connect");
  11.  
  12. //getting the username, and password for sanitizing
  13. $_US_username = $_POST['username'];
  14. $_US_password = $_POST['password'];
  15.  
  16. //sanitize the variable to remove SQL statements that could drop the database potentially.
  17. $username = mysql_real_escape_string($_US_username);
  18. $password = mysql_real_escape_string($_US_password);
  19.  
  20. $sql = "SELECT * FROM user WHERE username = '$username' AND password = '$password'";
  21. $result = mysqli_query($sql);
  22.  
  23. $numrows = mysql_num_rows($result);
  24.  
  25. if($numrows > 0)
  26. {
  27. while($row = mysqli_fetch_assoc($result))
  28. {
  29. echo "id: " . $row["userID"]. " - UserName: " . $row["username"]. " " . $row["password"]. " - Type: " . $row["type"]. "<br>";
  30. }
  31. }
  32. else
  33. {
  34. echo "username does not match!";
  35. }
  36. ?>
  37.  
  38. <!DOCTYPE html><!-- login.html -->
  39. <?php include "../php/action_page.php"; ?>
  40. <html>
  41. <head lang="en">
  42. <meta charset="UTF-8">
  43. <title>Login</title>
  44. <link href="css/login_2.css" rel="stylesheet">
  45. </head>
  46. <body>
  47. <div class="login-form">
  48. <form id = "login_form" action="php/action_page.php" method ="POST">
  49. <h1> Login </h1>
  50. <input type='hidden' name='submitted' id='submitted' value='1' />
  51.  
  52. <div class="form">
  53. <input type ="text" name='username' class="credentials-form" placeholder="Username" id="Username">
  54. </div>
  55. <div class="form data">
  56. <input type ="password" name='password' class="credentials-form" placeholder="Password" id="Password">
  57. </div>
  58. <input type='submit' name='Submit' value='Login' class='button'/>
  59. <button type="button" class="button" id="acc" onclick="location.href='createAccount.html';"><span>Create Account</span></button>
  60. </form>
  61. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement