Guest User

Untitled

a guest
Dec 13th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. //require_once ("config.php");
  4. //ob_start();
  5. session_start();
  6.  
  7. //$error = false;
  8. //$msg = '';
  9.  
  10. //$username=$_POST['username'];
  11. //$password=$_POST['password'];
  12.  
  13.  
  14. //$query = $DBH->prepare("SELECT * FROM Users WHERE Nickname='$username' and Passwrd='$password'");
  15.  
  16. if (isset($_POST['submit'])) {
  17.  
  18. include_once ('config.php');
  19.  
  20. $username = $_POST['username'];
  21. $password = $_POST['password'];
  22.  
  23. //error jutut
  24. //tyhjät kohdat
  25. if (empty($username) || empty($password)) {
  26. header("Location: index.html?login=empty");
  27. exit();
  28. } else {
  29. $sql = "SELECT * FROM Users WHERE Nickname='$username'";
  30. $param = array('username' => $username);
  31. $query = $DBH->prepare($sql);
  32. $query->execute($param);
  33. $row = $query->fetch();
  34.  
  35. if ($query-> rowCount == 0 ) {
  36. header("Location: index.html?login=error");
  37. exit();
  38. //dehässäys salasanalle
  39. } else {
  40. if ()
  41. $hashpasswordcheck = password_verify($password, $row['password']);
  42. if ($hashpasswordcheck == false) {
  43. header("Location: index.html?login=error2");
  44. exit();
  45. } elseif ($hashpasswordcheck == true) {
  46. //login
  47. $_SESSION['username']= $row['username'];
  48. $_SESSION['email']= $row['email'];
  49. header("Location: index.html?login=success");
  50. exit();
  51. }
  52. }
  53. }
  54.  
  55. } else {
  56. header("Location: index.html?login=errorSOS");
  57. exit();
  58. }
Add Comment
Please, Sign In to add comment