I have a form that shows different questions depending on what the user selects. My problem is, if the user doesn’t not make it through the forms validation, the inputs the user entered do not refill. The user would have to restart all over again, and I don’t want that to happen, but I cant figure out whats going on.
Here I posted my code below. Its too long so I will post the rest in the next post, thankyou for your help! This is driving me crazy.
[CODE]<?
$additionalDetails = $_POST[‘details’];
$backInformation = $_POST[‘backInformation’];
$deadline = $_POST[‘deadline’];
$designIdeas = $_POST[‘ideas’];
$email = $_POST[’email’];
$emailSubject = ‘WetGFX Quote’;
$extra = $_POST[‘extra’];
$frontInformation = $_POST[‘frontInformation’];
$headers = “From: $emailrn”;
$headers .= “Content-type: text/htmlrn”;
$logoText = $_POST{‘logoText’};
$myspaceName = $_POST[‘myspaceName’];
$name = $_POST[‘name’];
$other = $_POST[‘other’];
$project = $_POST[‘project’];
$projectPurpose = $_POST[‘purpose’];
$sectionType = $_POST[‘sectionType’];
$sizingIrregular = $_POST[‘sizingIrregular’];
$sizingFB = $_POST[‘sizingFB’];
$sizingSides = $_POST[‘sizingSides’];
$sizingTB = $_POST[‘sizingTB’];
$urlname = urlencode($$_POST[‘name’]);
$message = “”;
$emailclass = “basictext”;
$username = “”;
// check project type selection
$projectSelection = $_POST[‘project’];
$brochureSelect = ‘unchecked’;
$businessCardSelect = ‘unchecked’;
$CDcoverSelect = ‘unchecked’;
$flyerSelect = ‘unchecked’;
$logoSelect = ‘unchecked’;
$myspaceSelect = ‘unchecked’;
$productPackagingSelect = ‘unchecked’;
$websiteSelect = ‘unchecked’;
$otherSelect = ‘unchecked’;
if ($projectSelection == ‘Brochure’) {
$brochureSelect = ‘checked’;
}
else if ($projectSelection == ‘Business Card’) {
$businessCardSelect = ‘checked’;
}
else if ($projectSelection == ‘CD Cover’) {
$CDcoverSelect = ‘checked’;
}
else if ($projectSelection == ‘Flyer’) {
$flyerSelect = ‘checked’;
}
else if ($projectSelection == ‘Logo’) {
$logoSelect = ‘checked’;
}
else if ($projectSelection == ‘Myspace’) {
$myspaceSelect = ‘checked’;
}
else if ($projectSelection == ‘Product Packaging’) {
$productPackagingSelect = ‘checked’;
}
else if ($projectSelection == ‘Website’) {
$websiteSelect = ‘checked’;
}
else if ($projectSelection == ‘Other’) {
$otherSelect = ‘checked’;
}
// check amount of sides selection
$sidesSelection = $_POST[‘sides’];
if ($sidesSelection == ‘oneSide’) {
$oneSideSelect = ‘selected’;
}
else if ($sidesSelection == ‘twoSide’) {
$twoSideSelect = ‘selected’;
}
else if ($sidesSelection == ‘threeSide’) {
$threeSideSelect = ‘selected’;
}
else if ($sidesSelection == ‘fourSide’) {
$fourSideSelect = ‘selected’;
}
else if ($sidesSelection == ‘fiveSide’) {
$fiveSideSelect = ‘selected’;
}
else if ($sidesSelection == ‘sixSide’) {
$sixSideSelect = ‘selected’;
}
else if ($sidesSelection == ‘moreSide’) {
$moreSideSelect = ‘selected’;
}
// check section amount selection
$sectionAmount = $_POST[‘sections’];
if ($sectionAmount == ‘oneSection’) {
$sectionAmount1 = ‘selected’;
}
else if ($sectionAmount == ‘twoSection’) {
$sectionAmount2 = ‘selected’;
}
else if ($sectionAmount == ‘threeSection’) {
$sectionAmount3 = ‘selected’;
}
else if ($sectionAmount == ‘fourSection’) {
$sectionAmount4 = ‘selected’;
}
else if ($sectionAmount == ‘fiveSection’) {
$sectionAmount5 = ‘selected’;
}
else if ($sectionAmount == ‘moreSection’) {
$sectionAmountMore = ‘selected’;
}
if ($_POST[‘formValidation’] == 1) {
if (!ereg(“^[^@]{1,64}@[^@]{1,255}$”, $email))
{ // character and @ check
$message = “Please enter a valid email address.”;
$name = $_POST[‘name’];
$emailclass = “errortext”;
$email_array = explode(“@”, $email);
$local_array = explode(“.”, $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++)
{
if(!ereg(“^(([A-Za-z0-9!#$%&’*+/=?^_`{|}~-][A-Za-z0-9!#$%&
↪’*+/=?^_`{|}~.-]{0,63})|(“[^(\|”)]{0,62}”))$”,
$local_array[$i]))
$message = “Please enter a valid email address.”;
$name = $_POST[‘name’];
$emailclass = “errortext”;
$email_array = explode(“@”, $email);
$local_array = explode(“.”, $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++)
{
if(!ereg(“^(([A-Za-z0-9!#$%&’*+/=?^_`{|}~-][A-Za-z0-9!#$%&
↪’*+/=?^_`{|}~.-]{0,63})|(“[^(\|”)]{0,62}”))$”,
$local_array[$i]))
$message = “Please enter a valid email address.”;
$name = $_POST[‘name’];
$emailclass = “errortext”;
if (!ereg(“^[?[0-9.]+]?$”, $email_array[1]))
{ //ip check
$domain_array = explode(“.”, $email_array[1]);
if (sizeof($domain_array) < 2) {
$message = “Please enter a valid email address.”;
$name = $_POST[‘name’];
$emailclass = “errortext”;}//end if
for ($i = 0; $i < sizeof($domain_array); $i++)
{
if (!ereg(“^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
↪([A-Za-z0-9]+))$”,
$domain_array[$i])) {
$message = “Please enter a valid email address.”;
$name = $_POST[‘name’];
$emailclass = “errortext”;
if (!$email) { // blank input check
$message = “Please enter a valid email address.”;
$name = $_POST[‘name’];
$emailclass = “errortext”;}
}//end blank input check
}//end for
}//end ip check
}
}
} // end of character and @ check.
else if // valid form send
($projectSelection == ‘Brochure’){
mail($webMaster , $emailSubject, $body, $headers);
header(“location: quotecomplete.html”);
}// end send form
} // end formValidation
?>