-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.php
More file actions
45 lines (42 loc) · 1.31 KB
/
validate.php
File metadata and controls
45 lines (42 loc) · 1.31 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();
$user = "root";
$pass = "";
$db = "library";
$con = new mysqli("localhost", $user, $pass, $db) or die("Unable to connect");
$id = $_POST["id"];
$pass = $_POST["password"];
$query = "select ID, password, name from student where ID = '$id'";
$result = mysqli_query($con, $query);
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
//$num = mysqli_num_rows($result);
//print_r(array_keys($rows));
if (mysqli_num_rows($result) == 0)
{
header("location: http://localhost/Library Management System/signin&signup.php");
} elseif ($rows["0"]["password"] != $pass)
{
header("location: http://localhost/Library Management System/signin&signup.php");
} else
{
$_SESSION['id'] = $id;
$_SESSION['name'] = $rows["0"]["name"];
$_SESSION['user_type'] = "user";
//print_r(array_keys($rows));
//print_r($rows["0"]);
// printf($rows["0"]["Name"]);
header("location: http://localhost/Library Management System/home.php");
}
// if ($num == 1)
// {
// $_SESSION['id'] = $id;
// $_SESSION['name'] = $rows["0"]["Name"];
// $_SESSION['user_type'] = "user";
// // print_r(array_keys($rows));
// // printf($rows["0"]["Name"]);
// header("location: http://localhost/Library Management System/home.php");
// } else
// {
// header("location: http://localhost/Library Management System/signin&signup.php");
// }
?>