<!-- STEP #1: cd C:\Users\Anuar\Documents\GitHub\anuar_epicodus\php -->
<!-- STEP #2: php -S localhost:8000 -->
<!-- Step #3: http://localhost:8000/shipping_calculator_ex.php -->
<?php 
$input_weight = $_GET["weight"];
$input_distance = $_GET["distance"];
$shipping_price = calculateShipping($input_weight, $input_distance);
function calculateShipping($weight, $distance)
{
    $price = $distance / $weight + 5;
    return $price;
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>Shipping Calculator</title>
</head>
<body>
    <div class="container">
        <h1>Price Calculated!</h1>
        <h3>Your package weighs: <?php 
echo $input_weight . " lbs";
?>
 </h3>
        <h3>Your package is traveling: <?php 
echo $input_distance . " miles";
?>
 </h3>
        <h3>The cost will be: $<?php 
echo $shipping_price;
Пример #2
0
?>
" />
<input name="city" type="hidden" value="<?php 
echo $_POST["city"];
?>
" />
<input name="state" type="hidden" value="<?php 
echo $_POST["state"];
?>
" />
<input name="zip" type="hidden" value="<?php 
echo $_POST["zip"];
?>
" />
<input name="shipping" type="hidden" value="<?php 
echo calculateShipping($_POST['shipping']);
?>
" />
<input name="total" type="hidden" value="<?php 
echo $total;
?>
" />

<table border="0" width="100%" >
<tr>
<td colspan="2"><p><b>Credit Card Information:</b></p></td>
</tr>
<tr>
<td>Card Number: &nbsp;</td>
<td><input name="cardnumber" type="text" size="50" placeholder="" /></td></tr>
<tr><td>Name on Card: &nbsp;</td>