-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
90 lines (85 loc) · 2.28 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
session_start();
include_once 'dbconnect.php';
if(isset($_SESSION['user'])!="")
{
if($_SESSION['category']=="teacher")
header("Location: teachermyprofile.php");
else if($_SESSION['category']=="student")
header("Location: studentmyprofile.php");
}
if((isset($_POST['btn-login'])))
{
$_SESSION['category'] = $_POST['logincat'];
$login_id = $_POST['email'];
$password = $_POST['pass'];
if($_POST['logincat']=="teacher")
{
$res=mysqli_query($bd,"SELECT * FROM teacher WHERE login_id='$login_id' and password='$password'");
$row=mysqli_fetch_array($res);
if($row['password'] == $password)
{
$_SESSION['user'] = $row['id'];
header("Location: teachermyprofile.php");
}
}
else if($_POST['logincat']=="student")
{
$res=mysqli_query($bd,"SELECT * FROM student WHERE login_id='$login_id' and password='$password'");
$row=mysqli_fetch_array($res);
if($row['password'] == $password)
{
$_SESSION['user'] = $row['id'];
header("Location: studentmyprofile.php");
}
}
else if($_POST['logincat']=="category")
{
?>
<script>alert('Select a Login Category');</script>
<?php
}
if((!isset($_SESSION['user']))&&$_POST['logincat']!="category")
{
?>
<script>alert('Wrong Details');</script>
<?php
}
}
?>
<?php include 'validation.php';
include 'header.php';
include 'homesidenavbar.php'; ?>
<div class="col-sm-9">
<div class="main" id="logindiv">
<center>
<h1>Login</h1>
<div class="login-form" >
<form method="post">
<table class="loggedin" style="padding:35px;">
<tr>
<td>
<select class="logincat" name="logincat" required="required">
<option value="category">Category</option>
<option value="student">Student</option>
<option value="teacher" >Teacher</option>
</select>
</td>
</tr>
<tr>
<td><input type="text" name="email" placeholder="Your Email" required /></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Your Password" required/></td>
</tr>
<tr>
<td><button type="submit" name="btn-login">Log In</button></td>
</tr>
</table>
</form>
</div>
</center>
</div>
</div>
</div>
<?php include 'footer.php'; ?>