-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
31 lines (25 loc) · 891 Bytes
/
Copy pathprocess.php
File metadata and controls
31 lines (25 loc) · 891 Bytes
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
<?php
session_start();
include 'db.php';
if (isset($_POST['register'])) {
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$dept = $_POST['department'];
$gender = $_POST['gender'] ?? 'Not Specified';
$others = $_POST['others'];
// Convert hobbies array to a single string
$hobbies = isset($_POST['hobbies']) ? implode(", ", $_POST['hobbies']) : "None";
$sql = "INSERT INTO users (first_name, last_name, department, gender, hobbies, others)
VALUES (?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssssss", $fname, $lname, $dept, $gender, $hobbies, $others);
if ($stmt->execute()) {
$_SESSION['message'] = "Registration Successful!";
} else {
$_SESSION['message'] = "Error: " . $conn->error;
}
$stmt->close();
header("Location: index.php");
exit();
}
?>