-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
47 lines (34 loc) · 939 Bytes
/
check.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "srp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user = $_POST["username"];
$pwd = $_POST["pwd"];
$sql = "select id,user_name,password from login";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
if ($row["user_name"]== $user && $row["password"] == $pwd)
{ session_start();
$_SESSION['login_id']= $row["id"];
$_SESSION['login_name']= $row["user_name"];
header("Location: home.php");
$sql2 = "insert into session values($_SESSION[login_id])";
if ($conn->query($sql2) === TRUE) {}
}
}
}
else {
echo "0 results";
}
mysqli_close($conn);
?>