Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'header.php';
- ?>
- <html>
- <head>
- <title>User Login Page</title>
- </head>
- <body>
- <?php
- if (!isset($_POST['submit'])){
- ?>
- <!-- The HTML login form -->
- <div class="container">
- <h1 class="welcome text-center">Welcome to <br> Virtual Planner</h1>
- <div class="card card-container">
- <h2 class='login_title text-center'>Login</h2>
- <hr>
- <form action="<?=$_SERVER['PHP_SELF']?>" method="post" class="form-signin">
- <span id="reauth-email" class="reauth-email"></span>
- <p class="input_title">Email</p>
- <input name="username" type="text" id="inputEmail" class="login_box" placeholder="user01@virtualplanner.com" required autofocus>
- <p class="input_title">Password</p>
- <input type="password" name="password" id="inputPassword" class="login_box" placeholder="******" required>
- <label>
- </label>
- <input class="login_box btn-primary" type="submit" name="submit" value="Login" />
- <a href="ResetPassword.php" class="btn btn-sm btn-primary">Reset Student Password</a>
- </form><!-- /form -->
- </div><!-- /card-container -->
- </div><!-- /container -->
- <?php
- } else {
- require_once("conn.php");
- $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- # check connection
- if ($mysqli->connect_errno) {
- echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
- exit();
- }
- $username = $_POST['username'];
- $password = $_POST['password'];
- $sql = "SELECT * FROM `teacher` WHERE `Username` = '$username' AND `Password` = '$password' LIMIT 1";
- $result = $mysqli->query($sql);
- if ($result->num_rows > 0 ) {
- echo "<p>Logged in succsessfully<p/>";
- //$row = $result->fetch_assoc();
- $_SESSION['username']=$username;
- $_SESSION['password']=$password;
- while($row = $result->fetch_assoc()) {
- $_SESSION['Teacher_ID']=$row['Teacher_ID'];
- echo $row['Teacher_ID'];
- echo $row['Teacher_ID'];
- }
- echo "<script> window.location.assign('TeacherDashboard.php'); </script>";
- } else {
- $sql = "SELECT * FROM `student` WHERE `Username` = '$username' AND `Password` = '$password' LIMIT 1";
- $result = $mysqli->query($sql);
- if ($result->num_rows > 0 ) {
- echo "<p>Logged in succsessfully<p/>";
- //$row = $result->fetch_assoc();
- $_SESSION['username']=$username;
- $_SESSION['password']=$password;
- while($row = $result->fetch_assoc()) {
- $_SESSION['Student_ID']=$row['Student_ID'];
- }
- echo "<script> window.location.assign('StudentDashboard.php'); </script>";
- }else{
- echo '<script language="javascript">';
- echo 'alert("Login Failed Please Make Sure Username and Password are correct")';
- echo '</script>';
- echo "<script> window.location.assign('index1.php'); </script>";
- }
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement