<?php
require_once 'Session.php';
$session = new Session();
$address = $session->read( 'user_address' );
if( !$address ) {
header( 'Location: index.html' );
exit;
}
function escape( $value ) {
return htmlspecialchars( $value ?? '', ENT_QUOTES, 'UTF-8' );
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>autónoma – payment</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<h1>autónoma – payment</h1>
<form action="process_payment.php" method="post">
<p>
Provide your credit card details to complete the purchase. Upon
completing the purchase, a custom book will be generated within
24 hours, printed, and shipped.
</p>
<p>
Shipping may take up to 15 business days.
</p>
<p>
<label for="card_number">Card number:</label>
<input type="text" id="card_number" name="card_number"
maxlength="19" required autofocus="autofocus"
placeholder="1234 5678 9012 3456">
</p>
<p>
<label for="cardholder_name">Cardholder name:</label>
<input type="text" id="cardholder_name" name="cardholder_name"
maxlength="100" required>
</p>
<p>
<label for="expiry_month">Expiry month:</label>
<select id="expiry_month" name="expiry_month" required>
<option value="">Month</option>
<?php
for( $month = 1; $month <= 12; $month++ ) {
$mCode = str_pad( $month, 2, '0', STR_PAD_LEFT );
$mName = date( 'F', mktime( 0, 0, 0, $month, 1 ) );
echo "<option value=\"$mCode\">$mCode - $mName</option>\n";
}
?>
</select>
</p>
<p>
<label for="expiry_year">Expiry year:</label>
<select id="expiry_year" name="expiry_year" required>
<option value="">Year</option>
<?php
$current_year = date( 'Y' );
for( $i = 0; $i < 15; $i++ ) {
$year = $current_year + $i;
echo "<option value=\"$year\">$year</option>";
}
?>
</select>
</p>
<p>
<label for="cvv">CVV:</label>
<input type="text" id="cvv" name="cvv" maxlength="4"
required placeholder="123">
</p>
<p>
<label for="billing_postcode">Billing postal code:</label>
<input type="text" id="billing_postcode" name="billing_postcode"
maxlength="20" required>
</p>
<p>
<button type="submit">Complete purchase</button>
</p>
</form>
</body>
</html>