Create an online flight registration form. On the first page accept name, address,
birthdate, and mobile number. On the second page accept flight details (flight name, source,
destination, departure date-time and charges). If the user doesn’t enter information within a
specified time limit, expire his session and give a warning otherwise display details using
sessions on the third page.
//page1.
php
<?php
session_start();
// Set session timeout duration (60 seconds)
$_SESSION['timeout'] = time() + 60;
?>
<!DOCTYPE html>
<html>
<head>
<title>Flight Registration - Personal Details</title>
</head>
<body>
<h2>Personal Details</h2>
<form method="post" action="page2.php">
Name: <input type="text" name="name" required><br><br>
Address: <input type="text" name="address" required><br><br>
Birthdate: <input type="date" name="birthdate" required><br><br>
Mobile No: <input type="text" name="mobile" required><br><br>
<input type="submit" value="Next">
</form>
</body>
</html>
//page2.php
<?php
session_start();
// Check session timeout
if (!isset($_SESSION['timeout']) || time() > $_SESSION['timeout']) {
session_destroy();
die("Session expired! Please start again.");
}
// Reset timeout
$_SESSION['timeout'] = time() + 60;
// Store personal details
$_SESSION['name'] = $_POST['name'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['birthdate'] = $_POST['birthdate'];
$_SESSION['mobile'] = $_POST['mobile'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Flight Registration - Flight Details</title>
</head>
<body>
<h2>Flight Details</h2>
<form method="post" action="page3.php">
Flight Name: <input type="text" name="flight_name" required><br><br>
Source: <input type="text" name="source" required><br><br>
Destination: <input type="text" name="destination" required><br><br>
Departure Date-Time: <input type="datetime-local" name="departure" required><br><br>
Charges: <input type="number" name="charges" required><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
//page3.php
<?php
session_start();
// Check session timeout
if (!isset($_SESSION['timeout']) || time() > $_SESSION['timeout']) {
session_destroy();
die("Session expired! Please start again.");
}
// Reset timeout
$_SESSION['timeout'] = time() + 60;
// Store flight details
$_SESSION['flight_name'] = $_POST['flight_name'];
$_SESSION['source'] = $_POST['source'];
$_SESSION['destination'] = $_POST['destination'];
$_SESSION['departure'] = $_POST['departure'];
$_SESSION['charges'] = $_POST['charges'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Registration Details</title>
</head>
<body>
<h2>Registration Successful!</h2>
<h3>Personal Details</h3>
Name: <?php echo $_SESSION['name']; ?><br>
Address: <?php echo $_SESSION['address']; ?><br>
Birthdate: <?php echo $_SESSION['birthdate']; ?><br>
Mobile: <?php echo $_SESSION['mobile']; ?><br><br>
<h3>Flight Details</h3>
Flight Name: <?php echo $_SESSION['flight_name']; ?><br>
Source: <?php echo $_SESSION['source']; ?><br>
Destination: <?php echo $_SESSION['destination']; ?><br>
Departure: <?php echo $_SESSION['departure']; ?><br>
Charges: <?php echo $_SESSION['charges']; ?><br>
</body>
</html>
