-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.php
More file actions
35 lines (31 loc) · 1.36 KB
/
connect.php
File metadata and controls
35 lines (31 loc) · 1.36 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
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
$user_name = $_POST['user_name'];
$user_mail = $_POST['user_mail'];
$user_number = $_POST['user_number'];
$user_address = $_POST['user_address'];
$user_city = $_POST['user_city'];
$preferreddays = $_POST['preferreddays'];
$zip_code = $_POST['zip_code'];
$skills = $_POST['skills'];
$volunteerlocation = $_POST['volunteerlocation'];
//Database connection
$conn = new mysqli( 'localhost:8889','root','root','test_index');
if ($conn->connect_error) {
die('Connection failed: ' .$conn->connect_error);
} else {
$stmt = $conn->prepare('insert into index_data(user_name, user_mail, user_number, user_address, user_city, preferreddays, zip_code, skills, volunteerlocation)
values(?,?,?,?,?,?,?,?,?)');
$response = implode(', ', $_POST['skills']);
if (!$stmt) {
die('Prepare failed: ' . $conn->error);
}
$stmt ->bind_param('ssisssiss', $user_name, $user_mail, $user_number, $user_address, $user_city, $preferreddays, $zip_code, $response, $volunteerlocation);
$stmt -> execute();
echo "Thank you for signing up! Registration successful!";
$stmt -> close();
$conn ->close();
}
echo '<button onclick="window.location.href = \'homepage.html\';">Back to Homepage</button>';
?>