Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $noNavbar=''; // to remove navbar from this page
- $pageTitle= 'Login';
- if (isset($_SESSION['Username']) && isset($_SESSION['Type'])) {
- if($_SESSION['Type'] == 'broker'){
- header('Location: managers.php');
- exit();
- }
- elseif ($_SESSION['Type']== 'hotel') {
- # code... // header to hotel page
- }
- elseif ($_SESSION['Type']=='customer') {
- # code... // header to customer page
- }
- }
- include 'connect.php';
- $tpl='includes/templates/';
- include 'includes/functions/function.php';
- include 'includes/languages/english.php';
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8"/>
- <title><?php getTitle(); ?></title>
- <link rel="stylesheet" href="layout/css/bootstrap.min.css">
- <link rel="stylesheet" href="layout/css/font-awesome.min.css">
- <link rel="stylesheet" href="layout/css/style.css">
- </head>
- <body id="loginpage">
- <?php
- if(!isset($noNavbar)){
- include $tpl . 'navbar.php';
- }
- if ($_SERVER['REQUEST_METHOD']=='POST'){
- $username=$_POST["user"];
- $password=$_POST["pass"];
- $hashedpass=sha1($password);
- $type=$_POST["radio"];
- if($type=="User"){
- // Checking if user exists
- $stmt=$con->prepare("SELECT customerId FROM customer WHERE username =? AND password=? "); // change users to name of the table
- $stmt->execute(array($username,$password)); // don't forget to make it hashedpass
- $count=$stmt->rowCount();
- $row=$stmt->fetch();
- if($count > 0){
- $stmt=$con->prepare("SELECT * FROM suspendedcustomersaccounts WHERE suspendedCustomerId= ? "); // change users to name of the table
- $stmt->execute(array($row['customerId'])); // don't forget to make it hashedpass
- $count=$stmt->rowCount();
- $row=$stmt->fetch();
- if($count>0 ){
- $days = $_POST['days'];
- $hours = $_POST['hours'];
- strtotime("now + ". $days ."days" . " + " . $hours ." hours") - strtotime(row['suspensionDate']))/(60*60*24)
- }
- $_SESSION['Username']=$username;
- // customer
- $_SESSION['Type']= 'Customer';
- header('Location: members.php'); // change it to customer page
- exit();
- }
- }
- if($type=="Hotel"){
- // Checking if user exists
- $stmt=$con->prepare("SELECT hotelid FROM hotel WHERE username =? AND password=? "); // change users to name of the table
- $stmt->execute(array($username,$password)); // don't forget to make it hashedpass
- $count=$stmt->rowCount();
- $row=$stmt->fetch();
- if($count > 0){
- $_SESSION['Username']=$username;
- // customer
- $_SESSION['Type']= 'hotel';
- header('Location: managers.php'); // change it to customer page
- exit();
- }
- }
- if($type=="Broker"){
- // Checking if user exists
- $stmt=$con->prepare("SELECT brokerAccountId FROM brokeraccount WHERE username =? AND password=? "); // change users to name of the table
- $stmt->execute(array($username,$password)); // don't forget to make it hashedpass
- $count=$stmt->rowCount();
- $row=$stmt->fetch();
- if($count > 0){
- $_SESSION['Username']=$username;
- // customer
- $_SESSION['Type']= 'broker';
- header('Location: moderators.php'); // change it to customer page
- exit();
- }
- }
- }
- ?>
- <div id="formm" >
- <form class="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
- <input class="form-control" type="text" name="days" placeholder="days" required="required" >
- <input class="form-control" type="text" name="hours" placeholder="hours" required="required" >
- <h4 class="text-center"> Login </h4>
- <input class="form-control" type="text" name="user" placeholder="Username" autocomplete="off" required="required">
- <input class="form-control" type="password" name="pass" placeholder="Password" autocomplete="new-password" required="required">
- <div class="bla">
- <input class="form-check-input" type="radio" name="radio" id="inlineRadio1" value="Broker">
- <label class="form-check-label" >Broker</label>
- <input class="form-check-input" type="radio" name="radio" id="inlineRadio2" value="User">
- <label class="form-check-label" >User</label>
- <input class="form-check-input" type="radio" name="radio" id="inlineRadio3" value="Hotel">
- <label class="form-check-label">Hotel</label>
- </div>
- <input class="btn btn-primary btn-block loginn" type="submit" value="Login">
- <a><button class="btn-danger btn sign">Register New User</button></a>
- <a><button class="btn-danger btn sign1">Register New Hotel</button></a>
- </form>
- </div>
- <?php
- include $tpl. "footer.html";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement