Advertisement
karlokokkak

Untitled

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