Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['login']))
  3. {
  4. include("db.php");
  5. $link = openDBConnection();
  6. // get the password from the form and create the hash
  7. // the escape-function is used to provide security
  8. $password = $_POST['password'];
  9. $username = $_POST['username'];
  10. $query = "SELECT * FROM kayttajat WHERE username ='".$username."'";
  11. $result = mysql_query($query);
  12. if($result != false)
  13. {
  14. $num_rows = mysql_num_rows($result);
  15. if($num_rows == 0)
  16. {
  17. print "<p>Login incorrect<p>";
  18. }
  19. while($row = mysql_fetch_assoc($result))
  20. {
  21. $real_password = $row['password'];
  22. if($password == $real_password)
  23. {
  24. session_start();
  25. $_SESSION['session_id'] = session_id();
  26. header("Location: index.php");
  27. }
  28. else
  29. {
  30. print "<p>Login incorrect<p>";
  31. }
  32. }
  33. }
  34. else
  35. {
  36. print "<p>Login incorrect<p>";
  37. }
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement