Advertisement
Guest User

Untitled

a guest
Mar 30th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. <?php
  2. require_once( '.' . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "boot.php");
  3.  
  4. if (isset($_SESSION['student'])) {
  5. header("Location: students/index.php");
  6. }
  7.  
  8. if (isset($_SESSION['teacher'])) {
  9. header("Location: teachers/index.php");
  10. }
  11.  
  12.  
  13.  
  14. ?>
  15.  
  16.  
  17. <!DOCTYPE html>
  18. <html lang="en">
  19. <head>
  20. <meta charset="utf-8">
  21. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  22. <meta name="description" content="">
  23. <meta name="author" content="">
  24. <link rel="icon" href="../../favicon.ico">
  25.  
  26. <title><?php echo $language['main_title'];?></title>
  27.  
  28.  
  29. <!-- Bootstrap Core CSS -->
  30. <link href="css/bootstrap.css" rel="stylesheet">
  31. <link href="css/home_style.css" rel="stylesheet">
  32. <!-- javascript -->
  33. <link href="libs/validationEngine/validationEngine.jquery.css" rel="stylesheet">
  34.  
  35.  
  36. </head>
  37. <body background="images/bg.jpg" style="background-size: fixed cover; background-repeat: no-repeat;">
  38.  
  39. <?php
  40. error_reporting(E_ALL);
  41. ini_set('display_errors', 1);
  42. session_start();
  43.  
  44. if (isset($_POST['submit_teachers'])) {
  45. $teacher_name = ($_POST['teacher_name']);
  46. $teacher_pass = (md5($_POST['teacher_pass']));
  47.  
  48. $stmt_login = $connect->prepare("SELECT * FROM teachers WHERE username =:teacher_name AND password =:teacher_pass");
  49. $stmt_login->bindParam(':teacher_name', $teacher_name, PDO::PARAM_STR);
  50. $stmt_login->bindParam(':teacher_pass', $teacher_pass, PDO::PARAM_STR);
  51. $stmt_login->execute();
  52.  
  53. if ($stmt_login->rowCount() == 1) {
  54. $row = $stmt_login->fetch();
  55. $teacher_index = $row['teacher_index'];
  56.  
  57. $_SESSION['teacher'] = $teacher_name;
  58. $_SESSION['teacher_index'] = $teacher_index;
  59.  
  60. $token_rand = md5(uniqid(rand()));
  61. $_SESSION['token'] = $token_rand;
  62.  
  63. header("Location: teachers/index.php"); exit();
  64. }
  65. else {
  66. header("Location: index.php?login=error"); exit();
  67. }
  68. }
  69.  
  70. if (isset($_POST['submit_students'])){
  71. $student_name = ($_POST['student_name']);
  72. $student_pass = (md5($_POST['student_pass']));
  73.  
  74. $stmt_login = $connect->prepare("SELECT * FROM students WHERE username =:student_name AND password =:student_pass");
  75. $stmt_login->bindParam(':student_name', $student_name, PDO::PARAM_STR);
  76. $stmt_login->bindParam(':student_pass', $student_pass, PDO::PARAM_STR);
  77. $stmt_login->execute();
  78.  
  79.  
  80. if($stmt_login->rowCount() == 1) {
  81. $row = $stmt_login->fetch();
  82. $student_index = $row['student_index'];
  83.  
  84. $_SESSION['student'] = $student_name;
  85. $_SESSION['student_index'] = $student_index;
  86.  
  87. $token_rand = md5(uniqid(rand()));
  88. $_SESSION['token'] = $token_rand;
  89.  
  90. header("Location: students/index.php"); exit();
  91. }
  92. else {
  93. header("Location: index.php?login=error"); exit();
  94. }
  95. }
  96.  
  97.  
  98. ?>
  99. <br>
  100.  
  101. <center>
  102. <h2>Welcome to School Management System</h2>
  103. <button class="button" data-toggle="modal" data-target="#TeacherLogin" ><span>Teacher </span></button>
  104. <button class="button" data-toggle="modal" data-target="#StudentLogin"><span>Student </span></button>
  105. </center>
  106.  
  107. <!-- Teacher Login Form -->
  108.  
  109. <div class="modal fade" id="TeacherLogin" tabindex="-1" role="dialog" aria-labelledby="TeacherLogin" aria-hidden="true" style="display: none;">
  110. <div class="modal-dialog">
  111. <div class="loginmodal-container">
  112. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  113. <hr>
  114. <h1>Welcome to Teacher Login</h1><br>
  115. <form id="login_teacher" action="" method="post">
  116. <input type="text" name="teacher_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
  117. <input type="password" name="teacher_pass" class = "validate[required]" placeholder="<?php echo $language['password']; ?>"/>
  118. <input type="submit" name="submit_teachers" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
  119. </form>
  120. <div class="login-help">
  121. <a href="#">Forgot Password</a>
  122. </div>
  123. <hr>
  124. </div>
  125.  
  126. </div>
  127. </div>
  128.  
  129.  
  130. <!-- Student Login Form -->
  131.  
  132. <div class="modal fade" id="StudentLogin" tabindex="-1" role="dialog" aria-labelledby="StudentLogin" aria-hidden="true" style="display: none;">
  133. <div class="modal-dialog">
  134. <div class="loginmodal-container">
  135. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  136. <hr>
  137. <h1>Welcome to Student Login</h1><br>
  138. <form id="login_student" action="" method="post">
  139. <input type="text" name="student_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
  140. <input type="password" name="student_pass" placeholder="<?php echo $language['password']; ?>"/>
  141. <input type="submit" name="submit_students" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
  142. </form>
  143.  
  144. <div class="login-help">
  145. <a href="#">Forgot Password</a>
  146. </div>
  147. <hr>
  148. </div>
  149.  
  150. </div>
  151. </div>
  152.  
  153.  
  154.  
  155. <!-- jQuery -->
  156. <script src="js/jquery.min.js"></script>
  157.  
  158. <!-- Bootstrap Core JavaScript -->
  159. <script src="js/bootstrap.min.js"></script>
  160.  
  161. <!-- Initialize Bootstrap functionality -->
  162. <script>
  163. // Initialize tooltip component
  164. $(function () {
  165. $('[data-toggle="tooltip"]').tooltip()
  166. })
  167.  
  168. // Initialize popover component
  169. $(function () {
  170. $('[data-toggle="popover"]').popover()
  171. })
  172. </script>
  173.  
  174.  
  175.  
  176. </body>
  177. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement