-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn.php
41 lines (41 loc) · 1.52 KB
/
conn.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
<?php
$username = filter_input(INPUT_POST, 'username');
$password = filter_input(INPUT_POST, 'password');
if (!empty($username)) {
if (!empty($password)) {
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "Travel_Agency";
$conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ')'
. mysqli_connect_error());
} else {
$sql = "select C_Name, C_Pass from customer;";
$result = mysqli_query($conn, $sql);
$resultcheck = mysqli_num_rows($result);
if ($resultcheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
if ($row['C_Name'] == $username && $row['C_Pass'] == $password) {
echo "Log in succesful. Redirecting to Home page";
header("Location: timeout.html");
} else {
echo "Log in unsuccesful. Redirecting to Sign in page";
header("Location: signin.html");
}
}
}
if ($conn->query($sql)) {
echo "New Record is inserted succesfully";
} else {
echo "Error" . $sql . "<br>" . $conn->error;
}
$conn->close();
}
} else {
echo "Password should not be empty";
}
} else {
echo "Username should not be empty";
}