-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_request.php
More file actions
39 lines (34 loc) · 1.38 KB
/
Copy pathsubmit_request.php
File metadata and controls
39 lines (34 loc) · 1.38 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
<?php
session_start();
// Establish a database connection
include 'databaseConnection.php';
if ($error != null) {
echo '<p>Can\'t connect to DB';
} else {
echo '<p>Connected to DB';
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve form data
$room_type = $_POST["room-type"];
$height = $_POST["height"];
$width = $_POST["width"];
$design_category = $_POST["design-category"];
$color_preference = $_POST["colorPreference"];
$designer_id = $_POST["designerId"];
// Retrieve the client ID from the session
$client_id = $_SESSION['userID'];
$date = date('Y-m-d'); // Correct date format
// Insert the request into the database with a pending status
$sql = "INSERT INTO designconsultationrequest (roomTypeID, roomLength, roomWidth, designCategoryID, colorPreferences, clientID, designerID, statusID, date)
VALUES ('$room_type', '$height', '$width', '$design_category', '$color_preference', '$client_id', '$designer_id', '1', '$date')";
if (mysqli_query($connection, $sql)) {
header("Location: clientHomepage.php");
exit(); // Make sure to exit after redirection
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($connection);
}
} else {
echo "Invalid request";
}
}
?>