-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsuggestionsDB.php
49 lines (27 loc) · 937 Bytes
/
suggestionsDB.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
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
include 'mylib.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Establish database connection
$error = db_connect();
if ($error !== null) {
die("Connection failed: " . $error);
}
$userEmail = $_POST['userEmail'];
$subjectLine = $_POST['subjectLine'];
$description = $_POST['description'];
$query = $db->prepare("INSERT INTO suggestions (userEmail, subjectLine, description) VALUES (?, ?, ?)");
$query->bind_param("sss", $userEmail, $subjectLine, $description);
$query->execute();
if ($query->affected_rows > 0) {
header("Location: index.php");
//echo "<script>alert('Suggestion submitted successfully');</script>";
exit();
} else {
header("Location: index.php");
exit();
//echo "<script>alert('Error submitting suggestion);</script>";
}
$db->close();
}
?>