Advertisement
Guest User

Untitled

a guest
May 10th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2. require_once 'db_connect.php';
  3.  
  4. if((!isset($_POST['email']))||(!isset($_POST['password'])))
  5. {
  6. header('Location: index.php');
  7. exit();
  8. }
  9. else
  10. {
  11. if(empty($_POST['email']))
  12. {
  13. print_r("Enter valid e-mail");
  14. }
  15. else
  16. {
  17. if(empty($_POST['password']))
  18. {
  19. print_r("Enter valid password");
  20. }
  21. else
  22. {
  23. $dbconnect = new PDO('mysql:host=localhost;dbname=db_users',$user ,$pass);
  24. $received_email = $_POST['email'];
  25. $received_password = $_POST['password'];
  26. $select_user = "SELECT * FROM users WHERE email='".$received_email."' AND password='".$received_password."'";
  27. $statement = $dbconnect->query($select_user);
  28. $row_count = $statement->rowCount();
  29. $q = $dbconnect->query($select_user);
  30. $q->setFetchMode(PDO::FETCH_ASSOC);
  31. if($row_count != 1 )
  32. {
  33. print_r("Invalid username or password");
  34. }
  35. else
  36. {
  37. while ($row = $q->fetch()){
  38. echo htmlspecialchars($row['name']).'<br>';
  39. echo htmlspecialchars($row['surname']).'<br>';
  40. echo htmlspecialchars($row['nickname']).'<br>';
  41. }
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement