-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissuedata.php
55 lines (41 loc) · 1.6 KB
/
issuedata.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
// Connect to the MySQL database
$host = "localhost";
$username = "root";
$password = "";
$dbname = "studentdata";
$conn = mysqli_connect($host, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Check if the form has been submitted
if (isset($_POST['submit'])) {
// Get the form data
$student_name = $_POST['username'];
$email = $_POST['emailid'];
$gender = $_POST['gender'];
$group = $_POST['group-dropdown'];
$year = $_POST['year-dropdown'];
$issue_category = $_POST['problem-category-dropdown'];
$issue_description = $_POST['problem-description'];
// Insert the data into the database
$sql = "INSERT INTO issuedata (student_name, email, gender, stdgroup, grp_year, issue_category, issue_description)
VALUES ('$student_name', '$email', '$gender', '$group', '$year', '$issue_category', '$issue_description')";
if (mysqli_query($conn, $sql)) {
$user_id = mysqli_insert_id($conn);
mysqli_close($conn);
// Start a session to store the user ID and name
session_start();
// Store the user ID and name in session variables
$_SESSION['user_id'] = $user_id;
$_SESSION['student_name'] = $student_name;
// Redirect to the "submission_success.php" page
header("Location: submission_success.php");
exit(); // Ensure that the script stops executing after the redirect
} else {
echo "Error storing data: " . mysqli_error($conn);
}
}
// Close the connection
mysqli_close($conn);
?>