Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once( '.' . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "boot.php");
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- if (isset($_SESSION['student'])) {
- header("Location: students/index.php");
- }
- if (isset($_SESSION['teacher'])) {
- header("Location: teachers/index.php");
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <link rel="icon" href="../../favicon.ico">
- <title><?php echo $language['main_title'];?></title>
- <!-- Bootstrap Core CSS -->
- <link href="css/bootstrap.css" rel="stylesheet">
- <link href="css/home_style.css" rel="stylesheet">
- <!-- javascript -->
- <link href="libs/validationEngine/validationEngine.jquery.css" rel="stylesheet">
- </head>
- <body background="images/bg.jpg" style="background-size: fixed cover; background-repeat: no-repeat;">
- <?php
- if (isset($_POST['submit_teachers'])) {
- $teacher_name = ($_POST['teacher_name']);
- $teacher_pass = (md5($_POST['teacher_pass']));
- $stmt_login = $connect->prepare("SELECT * FROM teachers WHERE username = :teacher_name AND password = :teacher_pass");
- $stmt_login->bindParam(':teacher_name', $teacher_name, PDO::PARAM_STR);
- $stmt_login->bindParam(':teacher_pass', $teacher_pass, PDO::PARAM_STR);
- $stmt_login->execute();
- if ($stmt_login->rowCount() == 1) {
- $row = $stmt_login->fetch();
- $teacher_index = $row['teacher_index'];
- $_SESSION['teacher'] = $teacher_name;
- $_SESSION['teacher_index'] = $teacher_index;
- $token_rand = md5(uniqid(rand()));
- $_SESSION['token'] = $token_rand;
- header("Location: teachers/index.php"); exit();
- }
- else {
- header("Location: index.php?login=error"); exit();
- }
- }
- if (isset($_POST['submit_students'])){
- $student_name = ($_POST['student_name']);
- $student_pass = (md5($_POST['student_pass']));
- $stmt_login = $connect->prepare("SELECT * FROM students WHERE username = :student_name AND password = :student_pass");
- $stmt_login->bindParam(':student_name', $student_name, PDO::PARAM_STR);
- $stmt_login->bindParam(':student_pass', $student_pass, PDO::PARAM_STR);
- $stmt_login->execute();
- if($stmt_login->rowCount() == 1) {
- $row = $stmt_login->fetch();
- $student_index = $row['student_index'];
- $_SESSION['student'] = $student_name;
- $_SESSION['student_index'] = $student_index;
- $token_rand = md5(uniqid(rand()));
- $_SESSION['token'] = $token_rand;
- header("Location: students/index.php"); exit();
- }
- else {
- header("Location: index.php?login=error"); exit();
- }
- }
- ?>
- <br>
- <center>
- <h2>Welcome to School Management System</h2>
- <button class="button" data-toggle="modal" data-target="#TeacherLogin" ><span>Teacher </span></button>
- <button class="button" data-toggle="modal" data-target="#StudentLogin"><span>Student </span></button>
- </center>
- <!-- Teacher Login Form -->
- <div class="modal fade" id="TeacherLogin" tabindex="-1" role="dialog" aria-labelledby="TeacherLogin" aria-hidden="true" style="display: none;">
- <div class="modal-dialog">
- <div class="loginmodal-container">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <hr>
- <h1>Welcome to Teacher Login</h1><br>
- <form id="login_teacher" action="" method="post">
- <input type="text" name="teacher_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
- <input type="password" name="teacher_pass" class = "validate[required]" placeholder="<?php echo $language['password']; ?>"/>
- <input type="submit" name="submit_teachers" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
- </form>
- <div class="login-help">
- <a href="#">Forgot Password</a>
- </div>
- <hr>
- </div>
- </div>
- </div>
- <!-- Student Login Form -->
- <div class="modal fade" id="StudentLogin" tabindex="-1" role="dialog" aria-labelledby="StudentLogin" aria-hidden="true" style="display: none;">
- <div class="modal-dialog">
- <div class="loginmodal-container">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <hr>
- <h1>Welcome to Student Login</h1><br>
- <form id="login_student" action="" method="post">
- <input type="text" name="student_name" class = "validate[required]" placeholder="<?php echo $language['username']; ?>"/>
- <input type="password" name="student_pass" placeholder="<?php echo $language['password']; ?>"/>
- <input type="submit" name="submit_students" class="login loginmodal-submit" value="<?php echo $language['login']?>"/>
- </form>
- <div class="login-help">
- <a href="#">Forgot Password</a>
- </div>
- <hr>
- </div>
- </div>
- </div>
- <!-- jQuery -->
- <script src="js/jquery.min.js"></script>
- <!-- Bootstrap Core JavaScript -->
- <script src="js/bootstrap.min.js"></script>
- <!-- Initialize Bootstrap functionality -->
- <script>
- // Initialize tooltip component
- $(function () {
- $('[data-toggle="tooltip"]').tooltip()
- })
- // Initialize popover component
- $(function () {
- $('[data-toggle="popover"]').popover()
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement