Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2. require_once('connectvars.php');
  3.  
  4. if (isset($_POST['submit'])){
  5. // Connect to the database
  6. $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ("hiba");
  7.  
  8. $nev = $_POST['username'];
  9. $jelszo = $_POST['password'];
  10.  
  11. //mysql injction protection
  12.  
  13. $nev = mysqli_real_escape_string($dbc, trim($nev));
  14. $jelszo = mysqli_real_escape_string($dbc, trim($jelszo));
  15.  
  16. // Look up the username and password in the database
  17. $query = "SELECT user_id,username,password FROM mismatch_user WHERE username = '$nev' AND password = SHA('$jelszo')" or die("hiba".mysqli_error());
  18. $data = mysqli_query($dbc, $query);
  19.  
  20. if (mysqli_num_rows($data) == 1) {
  21. // The log-in is OK so set the user ID and username variables
  22. $row = mysqli_fetch_array($data);
  23. $user_id = $row['user_id'];
  24. $username = $row['username'];
  25. // Confirm the successful log-in
  26. echo('<p class="login">You are logged in as ' . $username . '.</p>');
  27.  
  28. }
  29. else {
  30. // The username/password are incorrect so send the authentication headers
  31. echo "hiba";
  32. }
  33.  
  34. }
  35.  
  36. ?>
  37. <html>
  38. <h2> Login </h2>
  39. <form method="post" action="login.php" enctype="multipart/form-data">
  40. <label>Username:</label>
  41. <input type="text" name="username"><br>
  42. <label>Password:</label>
  43. <input type="password" name="password"> <br>
  44. <input type="submit" value="Login" name="submit">
  45. </form>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement