Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <?php
- session_start();
- include ('connection.php');
- if (isset($_POST['user']) and isset($_POST['password'])){
- $username = $_POST['user'];
- $password = $_POST['password'];
- $query = "SELECT * FROM users WHERE stud_matricno ='$username' and stud_password='$password'";
- $result = mysqli_query($conn, $query) or die(mysqli_error($conn));
- $get_log = mysqli_fetch_assoc($result);
- $count = mysqli_num_rows($result);
- if ($count == 1){
- $_SESSION['user'] = $username;
- while($row = mysqli_fetch_assoc($result)) {
- $status = $row["status"];
- }
- if($status == 'student'){
- $qr_log1 = "SELECT * FROM users WHERE stud_matricno ='$username'";
- $result1 = mysqli_query($conn,$qr_log1);
- $get_log1 = mysqli_fetch_assoc($result1);
- $get_password = $get_log1['stud_password'];
- $get_username = $get_log1['stud_matricno'];
- if($password !== $get_password)
- {
- print "<script language=\"javascript\" type=\"text/javascript\">
- <!--
- window.setTimeout('window.location=\"index.php\"; ',0);
- //-->
- </script> ";
- echo "<script type='text/javascript'>alert('Wrong password. Please try again!');</script>";
- echo mysqli_error($con);
- }
- else
- {
- $_SESSION['stud_matricno']=$get_username;
- print "<script language=\"javascript\" type=\"text/javascript\">
- <!--
- window.setTimeout('window.location=\"student.php\"; ',0);
- //-->
- </script> ";
- echo "<script>alert('Congratulation, you have sucessful login into the site!');</script>";
- }
- }elseif ($status == 'staff'){
- header("location: /completeise/staff/content/index.php");
- }else if ($status == 'admin'){
- header("location: /completeise/admin/content/index.php");
- }
- } else{
- print "<script language=\"javascript\" type=\"text/javascript\">
- <!--
- window.setTimeout('window.location=\"error.php\"; ',0);
- //-->
- </script> ";
- echo "<script>alert('Username not registered yet!');</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement