Advertisement
Guest User

Untitled

a guest
May 5th, 2017
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. <?php
  2. include 'header.php';
  3. ?>
  4.  
  5. <html>
  6.  
  7. <head>
  8. <title>User Login Page</title>
  9. </head>
  10.  
  11. <body>
  12.  
  13. <?php
  14. if (!isset($_POST['submit'])){
  15. ?>
  16. <!-- The HTML login form -->
  17.  
  18. <div class="container">
  19. <h1 class="welcome text-center">Welcome to <br> Virtual Planner</h1>
  20. <div class="card card-container">
  21. <h2 class='login_title text-center'>Login</h2>
  22. <hr>
  23.  
  24. <form action="<?=$_SERVER['PHP_SELF']?>" method="post" class="form-signin">
  25. <span id="reauth-email" class="reauth-email"></span>
  26. <p class="input_title">Email</p>
  27. <input name="username" type="text" id="inputEmail" class="login_box" placeholder="user01@virtualplanner.com" required autofocus>
  28. <p class="input_title">Password</p>
  29. <input type="password" name="password" id="inputPassword" class="login_box" placeholder="******" required>
  30.  
  31. <label>
  32.  
  33. </label>
  34.  
  35.  
  36. <input class="login_box btn-primary" type="submit" name="submit" value="Login" />
  37. <a href="ResetPassword.php" class="btn btn-sm btn-primary">Reset Student Password</a>
  38. </form><!-- /form -->
  39. </div><!-- /card-container -->
  40. </div><!-- /container -->
  41.  
  42. <?php
  43. } else {
  44. require_once("conn.php");
  45. $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  46. # check connection
  47. if ($mysqli->connect_errno) {
  48. echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
  49. exit();
  50. }
  51.  
  52. $username = $_POST['username'];
  53. $password = $_POST['password'];
  54.  
  55. $sql = "SELECT * FROM `teacher` WHERE `Username` = '$username' AND `Password` = '$password' LIMIT 1";
  56. $result = $mysqli->query($sql);
  57. if ($result->num_rows > 0 ) {
  58. echo "<p>Logged in succsessfully<p/>";
  59. //$row = $result->fetch_assoc();
  60. $_SESSION['username']=$username;
  61. $_SESSION['password']=$password;
  62.  
  63.  
  64. while($row = $result->fetch_assoc()) {
  65.  
  66. $_SESSION['Teacher_ID']=$row['Teacher_ID'];
  67. echo $row['Teacher_ID'];
  68. echo $row['Teacher_ID'];
  69. }
  70.  
  71.  
  72. echo "<script> window.location.assign('TeacherDashboard.php'); </script>";
  73. } else {
  74. $sql = "SELECT * FROM `student` WHERE `Username` = '$username' AND `Password` = '$password' LIMIT 1";
  75. $result = $mysqli->query($sql);
  76. if ($result->num_rows > 0 ) {
  77. echo "<p>Logged in succsessfully<p/>";
  78. //$row = $result->fetch_assoc();
  79. $_SESSION['username']=$username;
  80. $_SESSION['password']=$password;
  81.  
  82.  
  83. while($row = $result->fetch_assoc()) {
  84.  
  85. $_SESSION['Student_ID']=$row['Student_ID'];
  86.  
  87. }
  88. echo "<script> window.location.assign('StudentDashboard.php'); </script>";
  89.  
  90.  
  91. }else{
  92.  
  93. echo '<script language="javascript">';
  94. echo 'alert("Login Failed Please Make Sure Username and Password are correct")';
  95. echo '</script>';
  96. echo "<script> window.location.assign('index1.php'); </script>";
  97. }
  98. }
  99. }
  100.  
  101. ?>
  102. </body>
  103. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement