exec("CREATE TABLE IF NOT EXISTS orders ( id INT AUTO_INCREMENT PRIMARY KEY, pickup_location VARCHAR(255) NOT NULL, delivery_location VARCHAR(255) NOT NULL, goods_description TEXT, estimated_weight DECIMAL(10, 2), status VARCHAR(50) DEFAULT 'PENDING', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );"); } catch (PDOException $e) { // In a real app, log this error. For this prototype, we'll show it. $message = 'Database setup failed: ' . $e->getMessage(); $message_type = 'danger'; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $pickup_location = $_POST['pickup_location'] ?? ''; $delivery_location = $_POST['delivery_location'] ?? ''; $goods_description = $_POST['goods_description'] ?? ''; $estimated_weight = $_POST['estimated_weight'] ?? ''; if (empty($pickup_location) || empty($delivery_location) || empty($estimated_weight)) { $message = 'Please fill in all required fields: Pickup Location, Delivery Location, and Estimated Weight.'; $message_type = 'warning'; } else { try { $sql = "INSERT INTO orders (pickup_location, delivery_location, goods_description, estimated_weight) VALUES (:pickup_location, :delivery_location, :goods_description, :estimated_weight)"; $stmt = $db->prepare($sql); $stmt->bindParam(':pickup_location', $pickup_location, PDO::PARAM_STR); $stmt->bindParam(':delivery_location', $delivery_location, PDO::PARAM_STR); $stmt->bindParam(':goods_description', $goods_description, PDO::PARAM_STR); $stmt->bindParam(':estimated_weight', $estimated_weight, PDO::PARAM_STR); if ($stmt->execute()) { $message = 'Your order has been placed successfully! A transporter will be in touch soon.'; $message_type = 'success'; } else { $message = 'There was an error placing your order. Please try again.'; $message_type = 'danger'; } } catch (PDOException $e) { $message = 'Database error: ' . $e->getMessage(); $message_type = 'danger'; } } } ?> Place an Order - LogPort

Place a New Shipment Order