Advertisement
lepasekat

Untitled

Aug 1st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. - Create by Sublime Text
  5. - user : lyop
  6. - PHP Version 5.6.24
  7. */
  8.  
  9. require_once ("../conn/conn.php");
  10. class Login{
  11. function startLogin(){
  12.  
  13. $connection = new Connection();
  14. $conn = $connection->getConnection();
  15.  
  16. try{
  17.  
  18. if (isset($_POST['submit'])) {
  19. if (empty($_POST['username']) || empty($_POST['password'])){
  20. header ('Location: errorLogin.php' );
  21. } else {
  22.  
  23. // var log
  24. $username = $_POST['username'];
  25. $password = $_POST['password'];
  26.  
  27. // query
  28. $log = "SELECT * FROM log";
  29. $result = $conn->prepare($log);
  30. $result->execute();
  31.  
  32. foreach ($result as $data) {
  33. if($username!=$data['username']){
  34. header ('Location: errorLogin.php');
  35. }
  36. else if($password!=$data['password']){
  37. header ('Location: errorLogin.php');
  38. }
  39. else if($username==$data['username']){
  40. header ('Location: ../display/display.php');
  41. }
  42. else if ($username==$data['username']) {
  43. header ('Location: ../display/display.php');
  44. }
  45. else ($password==$data['password']) {
  46. header ('Location: ../display/display.php');
  47. }
  48. }
  49. }
  50. }
  51. } catch (PDOException $e){
  52. echo "ERROR : ". $e->getMessage();
  53. }
  54.  
  55. }
  56. }
  57.  
  58. $login = new Login();
  59. $login->startLogin();
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement