-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbookflight.php
More file actions
50 lines (44 loc) · 1.77 KB
/
bookflight.php
File metadata and controls
50 lines (44 loc) · 1.77 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
46
47
48
49
50
<?php
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "rdbms";
$conn = new mysqli($host, $user, $pass, $dbname);
if($conn->connect_error){
die('Connection failed : '.$conn->connect_error);
}
else{
$email = $_POST["email"];
$password = $_POST["password"];
$seats = $_GET["seats"];
$guests = $_GET["guests"];
$airline = $_GET["airline"];
$from = $_GET["from"];
$to = $_GET["to"];
$departure = $_GET["departure"];
$arrival = $_GET["arrival"];
$date = $_GET["date"];
$class = $_GET["class"];
$sql = "SELECT password FROM signin where email = '$email'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
if($count == 1){
// Verify the user-provided password against the hashed password from the database
if (password_verify($password, $row['password'])){
$sql = "UPDATE flight SET seats = '$seats' where airline = '$airline' and source = '$from' and destination = '$to' and departure = '$departure' and arrival = '$arrival' and `date` = '$date' and class = '$class'";
$result = $conn-> query($sql);
$sql = "insert into flightbookings values ('$email', '$airline', '$from', '$to', '$departure', '$arrival', '$class', '$date', '$guests')";
$result = $conn-> query($sql);
}
else {
echo "failed";
header("Location: signin.php");
}
}
else {
echo "Login failed. Please verify through email.";
//header("Location: book.php");
}
}
?>