-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-process.php
More file actions
42 lines (35 loc) · 1.39 KB
/
upload-process.php
File metadata and controls
42 lines (35 loc) · 1.39 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
36
37
38
39
40
41
42
<?php
$servername = "localhost";
$username = "userr";
$password = "root";
$dbname = "userr";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get the form data
$fullName = $_POST["fullName"];
$emailAddress = $_POST["emailAddress"];
$mealName = $_POST["mealName"];
$categoryName = $_POST["categoryName"];
$instructions = $_POST["instructions"];
$picture = $_POST["picture"];
$videoLink = $_POST["videoLink"];
// Prepare the SQL statement
$stmt = $conn->prepare("INSERT INTO userRecipe (fullName, emailAddress, mealName, categoryName, instructions, picture, videoLink) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssssss", $fullName, $emailAddress, $mealName, $categoryName, $instructions, $picture, $videoLink);
// Execute the SQL statement
if ($stmt->execute()) {
$recipeID = $conn->insert_id; // Get the auto-generated ID of the inserted recipe
// Redirect to submission-report.php with query parameters
header("Location: submission-report.php?fullName=$fullName&emailAddress=$emailAddress&mealName=$mealName&categoryName=$categoryName&instructions=$instructions&picture=$picture&videoLink=$videoLink");
exit();
} else {
echo "Error: " . $stmt->error;
}
// Close the prepared statement and database connection
$stmt->close();
$conn->close();
?>