Freight Calculator

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Shipping Calculator</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background-color: #f9f9f9;
        }
        form {
            background: #ffffff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            max-width: 400px;
            margin: auto;
        }
        input[type="number"], select, button {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        button {
            background-color: #007bff;
            color: #fff;
            border: none;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>

<h1>Shipping Quote Calculator</h1>
<p>Enter the details below to calculate your shipping cost.</p>

<form action="" method="POST">
    <label for="weight">Package Weight (kg):</label>
    <input type="number" id="weight" name="weight" step="0.1" required>

    <label for="distance">Shipping Distance (km):</label>
    <input type="number" id="distance" name="distance" required>

    <label for="speed">Shipping Speed:</label>
    <select id="speed" name="speed">
        <option value="standard">Standard</option>
        <option value="express">Express</option>
    </select>

    <button type="submit">Calculate</button>
</form>

<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $weight = floatval($_POST['weight']);
    $distance = intval($_POST['distance']);
    $speed = $_POST['speed'];

    $base_rate = 5; // base rate per kg per km
    $speed_multiplier = ($speed === 'express') ? 1.5 : 1.0;

    $cost = $weight * $distance * $base_rate * $speed_multiplier;

    echo "<p><strong>Shipping Cost:</strong> $" . number_format($cost, 2) . "</p>";
}
?>

</body>
</html>