-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticipant_registration.php
37 lines (30 loc) · 1.08 KB
/
participant_registration.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
<?php
$link = mysqli_connect("localhost", "root", "", "event_registration");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Prepare an insert statement
$sql = "INSERT INTO participant (username, email, password) VALUES (?, ?, ?)";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "sss", $username, $email, $password);
// Set parameters
$username = $_REQUEST['user'];
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
header('Location:participant_registration_successfull.html');
} else{
header('Location:participant_registration_failed.html');
echo "ERROR: Could not prepare query: $sql. " . mysqli_error($link);
}
} else{
echo "ERROR: Could not prepare query: $sql. " . mysqli_error($link);
}
// Close statement
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($link);
?>