-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction.php
More file actions
executable file
·45 lines (43 loc) · 1.41 KB
/
function.php
File metadata and controls
executable file
·45 lines (43 loc) · 1.41 KB
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
<?php
session_start();
$_SESSION['status']="";
$_SESSION['type']=0;
$errors = array();
$db = mysqli_connect('localhost', 'root', '', 'test');
if( isset($_POST['sbmt']) ) {
$username = $_POST['t1'];
$password = $_POST['t2'];
$calue = $_POST['t3'];
if($calue == "Teacher") {
$sql="select * from teacher where user = '".$username."' AND password = '".$password."' limit 1";
$result= mysqli_query($db,$sql);
if (mysqli_num_rows($result) == 1) {
$_SESSION['username']=$_POST["t1"];
$_SESSION['status']="yes";
$_SESSION['type'] = 1;
echo "dfad";
header('location: tch/resources.php');
}
else {
array_push($errors, "Invalid usernanme or password!!!");
echo '<script type="text/javascript"> alert("Invalid username or password");</script>';
header('location: login.php');
echo "alert('dfadsfsd');"; }
}
else {
$sql="select * from loginform where user = '".$username."' AND password = '".$password."' limit 1";
$result= mysqli_query($db,$sql);
if (mysqli_num_rows($result) == 1) {
$_SESSION['username']=$_POST["t1"];
$_SESSION['status']="yes";
$_SESSION['type']=2;
header('location: tch/resources.php');
// header('location: index.html');
}
else {
array_push($errors, "Invalid usernanme or password!!!");
alert("Invalid username or password");
}
}
}
?>