Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $noNavbar=''; // to remove navbar from this page
  4. $pageTitle= 'Login';
  5. if (isset($_SESSION['Username']) && isset($_SESSION['Type'])) {
  6. if($_SESSION['Type'] == 'broker'){
  7. header('Location: managers.php');
  8. exit();
  9. }
  10.  
  11. elseif ($_SESSION['Type']== 'hotel') {
  12. # code... // header to hotel page
  13. }
  14. elseif ($_SESSION['Type']=='customer') {
  15. # code... // header to customer page
  16. }
  17.  
  18. }
  19. include 'connect.php';
  20. $tpl='includes/templates/';
  21. include 'includes/functions/function.php';
  22. include 'includes/languages/english.php';
  23. ?>
  24. <!DOCTYPE html>
  25. <html>
  26. <head>
  27. <meta charset="UTF-8"/>
  28. <title><?php getTitle(); ?></title>
  29. <link rel="stylesheet" href="layout/css/bootstrap.min.css">
  30. <link rel="stylesheet" href="layout/css/font-awesome.min.css">
  31. <link rel="stylesheet" href="layout/css/style.css">
  32. </head>
  33. <body id="loginpage">
  34. <?php
  35. if(!isset($noNavbar)){
  36.  
  37. include $tpl . 'navbar.php';
  38.  
  39.  
  40. }
  41. if ($_SERVER['REQUEST_METHOD']=='POST'){
  42. $username=$_POST["user"];
  43. $password=$_POST["pass"];
  44. $hashedpass=sha1($password);
  45. $type=$_POST["radio"];
  46.  
  47. if($type=="User"){
  48. // Checking if user exists
  49. $stmt=$con->prepare("SELECT customerId FROM customer WHERE username =? AND password=? "); // change users to name of the table
  50. $stmt->execute(array($username,$password)); // don't forget to make it hashedpass
  51. $count=$stmt->rowCount();
  52. $row=$stmt->fetch();
  53. if($count > 0){
  54. $stmt=$con->prepare("SELECT * FROM suspendedcustomersaccounts WHERE suspendedCustomerId= ? "); // change users to name of the table
  55. $stmt->execute(array($row['customerId'])); // don't forget to make it hashedpass
  56. $count=$stmt->rowCount();
  57. $row=$stmt->fetch();
  58. if($count>0 ){
  59.  
  60. $days = $_POST['days'];
  61. $hours = $_POST['hours'];
  62. strtotime("now + ". $days ."days" . " + " . $hours ." hours") - strtotime(row['suspensionDate']))/(60*60*24)
  63. }
  64. $_SESSION['Username']=$username;
  65. // customer
  66. $_SESSION['Type']= 'Customer';
  67. header('Location: members.php'); // change it to customer page
  68. exit();
  69. }
  70. }
  71. if($type=="Hotel"){
  72. // Checking if user exists
  73. $stmt=$con->prepare("SELECT hotelid FROM hotel WHERE username =? AND password=? "); // change users to name of the table
  74. $stmt->execute(array($username,$password)); // don't forget to make it hashedpass
  75. $count=$stmt->rowCount();
  76. $row=$stmt->fetch();
  77. if($count > 0){
  78. $_SESSION['Username']=$username;
  79. // customer
  80. $_SESSION['Type']= 'hotel';
  81. header('Location: managers.php'); // change it to customer page
  82. exit();
  83. }
  84. }
  85.  
  86. if($type=="Broker"){
  87. // Checking if user exists
  88. $stmt=$con->prepare("SELECT brokerAccountId FROM brokeraccount WHERE username =? AND password=? "); // change users to name of the table
  89. $stmt->execute(array($username,$password)); // don't forget to make it hashedpass
  90. $count=$stmt->rowCount();
  91. $row=$stmt->fetch();
  92. if($count > 0){
  93. $_SESSION['Username']=$username;
  94. // customer
  95. $_SESSION['Type']= 'broker';
  96. header('Location: moderators.php'); // change it to customer page
  97. exit();
  98. }
  99. }
  100.  
  101.  
  102. }
  103.  
  104.  
  105.  
  106.  
  107. ?>
  108.  
  109.  
  110.  
  111. <div id="formm" >
  112.  
  113. <form class="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
  114. <input class="form-control" type="text" name="days" placeholder="days" required="required" >
  115. <input class="form-control" type="text" name="hours" placeholder="hours" required="required" >
  116. <h4 class="text-center"> Login </h4>
  117. <input class="form-control" type="text" name="user" placeholder="Username" autocomplete="off" required="required">
  118. <input class="form-control" type="password" name="pass" placeholder="Password" autocomplete="new-password" required="required">
  119. <div class="bla">
  120. <input class="form-check-input" type="radio" name="radio" id="inlineRadio1" value="Broker">
  121. <label class="form-check-label" >Broker</label>
  122. <input class="form-check-input" type="radio" name="radio" id="inlineRadio2" value="User">
  123. <label class="form-check-label" >User</label>
  124. <input class="form-check-input" type="radio" name="radio" id="inlineRadio3" value="Hotel">
  125. <label class="form-check-label">Hotel</label>
  126. </div>
  127. <input class="btn btn-primary btn-block loginn" type="submit" value="Login">
  128. <a><button class="btn-danger btn sign">Register New User</button></a>
  129. <a><button class="btn-danger btn sign1">Register New Hotel</button></a>
  130.  
  131. </form>
  132. </div>
  133. <?php
  134. include $tpl. "footer.html";
  135.  
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement