index.php
index.php
php
//MySQL information
$servername = "localhost";
$username = "root";
$password = "Peron100906@";
$dbname = "event_registration";
//Variables
$totalPrice = 0;
$ticketCount = 0;
$name = "";
$email = "";
$purchaseId = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//get the amount of tickets and calculate the final price
$ticketCount = isset($_POST['tickets']) ? intval($_POST['tickets']) : 0;
$pricePerTicket = 30; //ticket price
$totalPrice = $ticketCount * $pricePerTicket;
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
//check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
} else {
echo "Error: " . $insert->error;
}
?>
<!doctype html>
<html lang="en">
<head>
<!--Meta datas-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Event Registration">
<title>PHP-Project</title>
<meta name="robots" content="noindex, nofollow">
<!--My CSS file-->
<link rel="stylesheet" href="./CSS/style.css">
</head>
<body>
<div id="main-div">
<img src="./IMG/ShowPoster.avif">
<div id="form-container">
<h2>Event Registration</h2>
<!--Button to navigate to Find Your Purchase page-->
<a href="find_purchase.php" id="find-purchase-btn">
<button class="btn" type="button">Find your purchase</button>
</a>
<form method="POST">
<!--Name field-->
<div class="form-group">
<label for="name">Full Name</label><br>
<input type="text" id="name" name="name" required>
</div>
<!--Card Number field-->
<div class="form-group">
<label for="card_number">Card Number</label><br>
<input type="text" id="card_number" name="card_number" maxlength="16" pattern="\d{16}" placeholder="1234 5678 9012 3456" required>
</div>
<!--CVV field-->
<div class="form-group">
<label for="cvv">CVV</label><br>
<input type="text" id="cvv" name="cvv" maxlength="3" pattern="\d{3}" placeholder="123" required>
</div>
<!--Expiration Date field-->
<div class="form-group">
<label for="expiry_date">Date</label><br>
<input type="date" id="expiry_date" name="expiry_date" required>
</div>
<!--Number of Tickets field-->
<div class="form-group">
<label for="tickets">Number of Tickets</label><br>
<input type="number" id="tickets" name="tickets" min="1" max="10" value="<?php echo $ticketCount; ?>" required>
</div>
<!--Email field-->
<div class="form-group">
<label for="email">Email</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<!--Submit Button-->
<button type="submit" class="btn">Register</button>
</form>
</div>
</div>
</body>
</html>