orderform1.php
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include('functions.php');
if ( $_POST ){
ordercheck();
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="shortcut icon" href="favicon.gif" type="image/vnd.microsoft.icon" />
<link rel="icon" href="favicon.gif" type="image/vnd.microsoft.icon" />
</head>
<body>
<div id="ocontainer">
<h1>
<center>
CD Order Form
</center>
</h1>
<hr />
<?php
if ( $_POST ){
if( $fail == true ){
echo "<div id=\"error\" >";
ordererror();
echo "</div><hr />";
}
}
?>
<div id="picture">
<h2> You are ordering:<br />
<br />
Audio Eye Candy<br />
<br />
<img src="aec.gif" /><br />
</h2>
</div>
<div id="content3">
<h3>
<?php
if( !$_POST || $fail == true ){
printform();
}
?>
<?php
if ( isset( $fail ) && $fail == false ){
echo "Please verify this information is correct.<br /><br />";
echo "Name: ".$_POST["fname"]." ".$_POST["lname"]."<br />";
echo "Email: <a href=\"mailto:".$_POST['email']."\">".$_POST['email']."</a><br />";
echo "Address: ".$_POST["address"]."<br />";
echo "City: ".$_POST["city"]."<br />";
echo "State: ".$_POST["state"]."<br />";
echo "Zip Code: ".$_POST["zip"]."<br />";
echo "CD's: ".$_POST["cd"]."<br />";
echo "Total: $".$total."<br />";
echo "Shipping: ".$_POST["shipping"]."<br />";
echo "How did you find out about our CD: ".$_POST["found"]."<br />";
echo "Comments: ".$_POST["comments"]."<br />";
}
?>
</h3>
</div>
</div>
</body>
</html>Code: Select all
<?php
/*
This code includes functions for displaying and checking an order form.
functions:
-ordercheck()
-ordererror()
-form()
*/
function ordercheck(){
global $fail;
$fail = false;
if( !isset( $_POST["fname"] ) ){
$_POST["fname"]="";
$fail=true;
}
if( !isset( $_POST["lname"] ) ){
$_POST["lname"]="";
$fail=true;
}
if( !isset( $_POST["email"] ) ){
$_POST["email"]="";
$fail=true;
}
if( !isset( $_POST["email"] ) ){
if( !filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL ) ){
$_POST["email"]="";
$fail=true;
}
}
if( !isset( $_POST["phonenumbera"] ) ){
$_POST["phonenumbera"]="";
$fail=true;
}
if( !isset( $_POST["phonenumberb"] ) ){
$_POST["phonenumberb"]="";
$fail=true;
}
if( !isset( $_POST["phonenumberc"] ) ){
$_POST["phonenumberc"]="";
$fail=true;
}
if( !isset( $_POST["address"] ) ){
$_POST["address"]="";
$fail=true;
}
if( !isset( $_POST["city"] ) ){
$_POST["city"]="";
$fail=true;
}
if( !isset( $_POST["zip"] ) ){
$_POST["zip"]="";
$fail=true;
}
if( !isset( $_POST["cd"] ) ){
$_POST["cd"]="";
$fail=true;
}
if( $fail == false ){
if( !isset ($_POST["shipping"] ) ){
$_POST["shipping"] = "No";
}
}
}
function ordererror(){
if( $_POST["fname"] == "" ){
echo "*Please enter your first name.<br />";
}
if( $_POST["lname"] == "" ){
echo "*Please enter your last name.<br />";
}
if( $_POST["email"] == "" ){
echo "*Please enter a valid email address.<br />";
}
if( $_POST["phonenumbera"] == "" || $_POST["phonenumberb"] == "" || $_POST["phonenumberc"] == "" ){
echo "*Please enter your phone number.<br />";
}
if( $_POST["address"] == "" ){
echo "*Please enter your address.<br />";
}
if( $_POST["city"] == "" ){
echo "*Please enter your city.<br />";
}
if($_POST["state"]== "--State--") {
echo "*Please select your state.<br />";
}
if( $_POST["zip"] == "" ){
echo "*Please enter your zip code.<br />";
}
if( $_POST["cd"] == "" ){
echo "*Please enter the number of CD's you are buying.<br />";
}
}
function printform(){
/*--CODE FOR A FORM HERE--(let me know if you want to see the form It displays content based on if the user has already input valid responses. Like it will set the input from last time and code it as the value="input" from the last accept.)*/
}