Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ob_start();
- require("../includes/header.php");
- if($_SERVER["REQUEST_METHOD"] == "POST"){
- $p_num = $_POST["username"];
- $pwd = $_POST["password"];
- ob_clean();
- $query = "SELECT * FROM `$user_table` WHERE `user_id` = '$p_num'";
- $result = mysqli_query($connect, $query) or die(mysqli_error($connect));
- while($row = mysqli_fetch_assoc($result)){
- $user_id = "{$row['user_id']}";
- $first_name = "{$row['first_name']}";
- $last_name = "{$row['last_name']}";
- $user_name = $first_name ." " .$last_name;
- $password = "{$row['password']}";
- $image = "{$row['image']}";
- $email = "{$row['email']}";
- $program = "{$row['program']}";
- $role = "{$row['role']}";
- $status = "{$row['logged_in']}";
- $registered = "{$row['registered']}";
- if(($user_id == $p_num) && password_verify($pwd, $password)){
- $_SESSION["id"] = $user_id;
- $_SESSION["user"] = $user_name;
- $_SESSION["program"] = $program;
- $_SESSION["pass"] = $password;
- $_SESSION["image"] = $image;
- $_SESSION["email"] = $email;
- $_SESSION["role"] = $role;
- $_SESSION["status"] = $status;
- $_SESSION["registered"] = $registered;
- $loggedin = "UPDATE `$user_table` SET `logged_in` = 1 WHERE `user_id` = '$user_id'";
- if($_SESSION["status"] == 1){
- header("Location: ../pages/denied_login.php");
- }
- elseif($_SESSION["registered"] == 0){
- header("Location: ../pages/not_registered.php");
- }
- else{
- header("Location: ../pages/instructor.php");
- mysqli_query($connect, $loggedin);
- }
- }
- else{
- header("Refresh: 1; URL=../index.php");
- }
- }
- echo json_encode(array("success"=>1));
- }
- $("#login").on("click", function(){
- $.post("../php/login.php", {}, function(response){
- if(response.success == "1"){
- location.replace("../pages/instructor.php");
- }
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement