-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-request-handler.php
More file actions
38 lines (33 loc) · 1.07 KB
/
Copy pathpost-request-handler.php
File metadata and controls
38 lines (33 loc) · 1.07 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
<?php
include 'db.php';
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: login.html');
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$title = $_POST['title'];
$description = $_POST['description'];
$category = $_POST['category'];
$user_id = $_SESSION['user_id'];
$sql = "INSERT INTO requests (title, description, category, user_id) VALUES ('$title', '$description', '$category', '$user_id')";
if ($conn->query($sql) === TRUE) {
header('Location: dashboard.php');
} else {
echo "Error: " . $conn->error;
}
}
$taskId = $_POST['task_id'];
$posterId = $_POST['poster_id'];
$amount = $_POST['amount'];
// Insert into escrow table
$stmt = $conn->prepare("INSERT INTO escrow (task_id, amount, status, task_poster_id) VALUES (?, ?, 'Pending', ?)");
$stmt->bind_param("idi", $taskId, $amount, $posterId);
if ($stmt->execute()) {
echo "Task posted and payment secured in escrow.";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>