This question already has an answer here:
I'm having trouble getting my PHP to show up. When I hit submit, it goes to a blank page instead of the invoice page where it prints out the information entered into the textboxes. Is that because my PHP is breaking the code? It should be correct unless I'm missing something.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Subscription</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="container">
<img src="images/BoxPage_BuluWeightLoss.png" alt="subscription box">
<h1>Health Package Subscription</h1>
<p>Please enter in the following information:</p>
<form class="wrap" action="invoice.php" method="post" name="subscribe">
<tr>
<h2>Billing Information:</h2>
<td>
<span class="labels">First name: </span>
<input type="text" name="billingfname">
</td>
<br>
<td>
<span class="labels"> Last name: </span>
<input type="text" name="billinglname">
</td>
<br>
<td>
<span class="labels">Address: </span>
<input type="text" name="billingaddress" style="width: 200px">
</td>
<br>
<td>
<span class="labels">City: </span>
<input type="text" name="billingcity">
</td>
<br>
<td>
<span class="labels">State: </span>
<input type="text" name="billingstate">
</td>
<br>
<td>
<span class="labels">Zip Code: </span>
<input type="text" name="billingzip" style="width: 80px">
</td>
<br>
<td>
<span class="labels">Telephone: </span>
<input type="text" name="billingphone" style="width: 100px">
</td>
</tr>
<tr>
<h2>Shipping Information:</h2>
<td>
<input class="shipping" type="checkbox" onchange="InputInformation(this)">Check if Shipping is the same as Billing
</td>
<br>
<td>
<span class="labels">First name: </span>
<input type="text" name="shippingfname">
</td>
<br>
<td>
<span class="labels"> Last name: </span>
<input type="text" name="shippinglname">
</td>
<br>
<td>
<span class="labels">Address: </span>
<input type="text" name="shippingaddress" style="width: 200px">
</td>
<br>
<td>
<span class="labels">City: </span>
<input type="text" name="shippingcity">
</td>
<br>
<td>
<span class="labels">State: </span>
<input type="text" name="shippingstate">
</td>
<br>
<td>
<span class="labels">Zip Code: </span>
<input type="text" name="shippingzip" style="width: 80px">
</td>
<br>
<td>
<span class="labels">Telephone: </span>
<input type="text" name="shippingphone" style="width: 100px">
</td>
</tr>
<br><br>
<div>
<span class = "labels">Subscription plan:</span>
<select size="3" name="package">
<option selected>Select One</option>
<option>Starter - $4.99</option>
<option>Premium - $9.99</option>
</select>
<br><br>
<span class="labels">Credit/Debit Card:</span>
<input type="text" name="payment">
<br><br>
<span class="labels">Expiration Date:</span>
<input type="text" name="month" style="width: 40px"> /
<input type="text" name="year" style="width: 40px">
<br><br>
<span class="labels">CSC: </span>
<input type="text" name="securityNumber" style="width: 50px">
<br>
<span class="labels">Coupon Code: </span><input type="text" name="coupon" style="width: 80px">
<br><br>
<input class="checkbox" type="checkbox" name="weekNews" value="1">Weekly Newsletter for Healthy Meal Plans
<br>
<input class="checkbox" type="checkbox" name="weekGiveaway" value="2">Weekly Giveaway Notifications
<br>
<input class="checkbox" type="checkbox" name="monthNews" value="3">Monthly Newsletter Package
</div>
<br><br>
<input class="button" type="submit" name="submitButton" value="Submit">
</form>
<?
$submit = $_POST['submitButton'];
$billFName = $_POST['billingfname'];
$billLName = $_POST['billinglname'];
$billAddress = $_POST['billingaddress'];
$billCity = $_POST['billingcity'];
$billState = $_POST['billingstate'];
$billZip = $_POST['billingzip'];
$billPhone = $_POST['billingphone'];
$shipFName = $_POST['shippingfname'];
$shipLName = $_POST['shippinglname'];
$shipAddress = $_POST['shippingaddress'];
$shipCity = $_POST['shippingcity'];
$shipState = $_POST['shippingstate'];
$shipZip = $_POST['shippingzip'];
$shipPhone = $_POST['shippingphone'];
$pay = $_POST['payment'];
$package = $_POST['package'];
$month = $_POST['month'];
$year = $_POST['year'];
$security = $_POST['securityNumber'];
if (isset($submit)) {
if ($submit == "" || $billFName == "" || $billLName == "" || $billAddress == "" || $billCity == "" || $billState == "" || $billZip == "" || $billPhone == "" || $shipFName == "" || $shipLName == "" || $shipAddress == "" || $shipCity == "" || $shipState == "" || $shipZip == "" || $shipPhone == "" || $pay == "" || $package =="" || $month == "" || $year == "" || $security == "")
{
echo("Please fill in all the required fields.");
} else {
echo ("Thank you!");
}
?>
</div>
<!--Script found at willmaster.com and adjusted for personal use with the help of Stack Overflow Forums-->
<script>
function InputInformation(n) {
if(n.checked === false) { return false; }
document.subscribe.shippingfname.value = document.subscribe.billingfname.value;
document.subscribe.shippinglname.value = document.subscribe.billinglname.value;
document.subscribe.shippingaddress.value = document.subscribe.billingaddress.value;
document.subscribe.shippingcity.value = document.subscribe.billingcity.value;
document.subscribe.shippingstate.value = document.subscribe.billingstate.value;
document.subscribe.shippingzip.value = document.subscribe.billingzip.value;
document.subscribe.shippingphone.value = document.subscribe.billingphone.value;
}
</script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire