The Website is website
The template holds a box that shows the form. The code from the page is
//header and other html code
if ($page_name == "inforequest"){
include("http://www.nebaptist.org/includes/majorform.php");
}else{
echo $page['page_data'];
}
//footer and more html code
The form displays fine the first time, but if there is an error it displays the form and error messages without any template at all. Replacing the includes with the actual code has not changed anything. I've tried many things but none of them have produced the desired result.
The script is:
<?php
//header("Cache-control: private");
// Validation
if ($_POST){
// prepare the errors var
unset($errors);
$errors = array();
//grab the vars into a more readable array var.
$formVars = $_POST;
if ((empty($formVars['firstname'])) || (empty($formVars['lastname'])) || (empty($formVars['age'])) || (empty($formVars['line1'])) || (empty($formVars['city'])) || (empty($formVars['state'])) || (empty($formVars['areacode'])) || (empty($formVars['firstnumber'])) || (empty($formVars['secondnumber']))) {
$errors['mistake'] = "<b>You Leftout the following required information, Please fill them out now. If Unknown, please put N/A,</b>";
if (empty($formVars['firstname']))
$errors['firstname'] = "Please provide your <b>first name</b>.<br>";
if (empty($formVars['lastname']))
$errors['lastname'] = "Please provide your <b>last name</b>.<br>";
if (empty($formVars['age']))
$errors['age'] = "Please provide your <b>age</b>.<br>";
if (empty($formVars['line1']))
$errors['line1'] = "Please provide your <b>address</b>.<br>";
if (empty($formVars['city']))
$errors['city'] = "Please provide the <b>city</b> for your address.<br>";
if (empty($formVars['state']))
$errors['state'] = "Please provide the <b>state</b> for your address.<br>";
if (empty($formVars['areacode']))
$errors['areacode'] = "Please provide the <b>area code</b> for your phone number.<br>";
if (empty($formVars['firstnumber']))
$errors['firstnumber'] = "Please provide your <b>phone number</b>.<br>";
if (empty($formVars['secondnumber']))
$errors['secondnumber'] = "Please provide your <b>phone number</b>.<br>";
}
// Error Count
if (count($errors) > 0){
include 'form.php';
}else{
// send email code
$to = "silentchim@aim.com";
$subject = "College Form";
$message = "
This is a form from someone interested in attending the college.
First Name:".$formVars['firstname']."
Last Name:".$formVars['lastname']."
Age:".$formVars['age']."
Address Line 1:".$formVars['line1']."
Address Line 2:".$formVars['line2']."
City:".$formVars['city'] ."
State:".$formVars['state'] ."
Phone Number:". $formVars['areacode'] ."-". $formVars['firstnumber'] ."-". $formVars['secondnumber']."
Email Address:". $formVars['email'] ."
Pastor's Name:" .$formVars['pastor']."
Church:" .$formVars['church'] ."
Major Interested In:" .$formVars['major']."
Graduation Date:". $formVars['month'] ."-". $formVars['year']."
Do not reply to this email. It is generated from a form on the website.
";
$from = "NewProspect";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "The information has been sent.Thank you.";
}
}else{
// show a blank.
// unset vars
unset($errors);
unset($formVars);
include 'form.php';
}
?>
And the actual form code is:
<form action="http://nebaptist.org/includes/majorform.php" method="post">
<table align="center" border="0" name="form" width="90%">
<tr>
<td>First Name*:</td>
<td><?php if (isset($errors['firstname'])){echo $errors['firstname'];} ?><input type="text" name="firstname" value="<?php echo $formVars['firstname']; ?>"><br></td>
<tr>
<td>Last Name*:</td>
<td><?php if (isset($errors['lastname'])){echo $errors['lastname'];} ?><input type="text" name="lastname" value="<?php echo $formVars['lastname']; ?>"><br></td>
<tr>
<td>Age*:</td>
<td><?php if (isset($errors['age'])){echo $errors['age'];} ?><input type="text" maxlength="2" size="2" name="age" value="<?php echo $formVars['age']; ?>"><br></td>
<tr>
<td>Address Line 1*:</td>
<td><?php if (isset($errors['line1'])){echo $errors['line1'];} ?><input type="text" name="line1" value="<?php echo $formVars['line1']; ?>"><br></td>
<tr>
<td>Address Line 2:</td>
<td><input type="text" name="line2" value="<?php echo $formVars['line2']; ?>"><br></td>
<tr>
<td>City*:</td>
<td><?php if (isset($errors['city'])){echo $errors['city'];} ?><input type="text" name="city" value="<?php echo $formVars['city']; ?>"><br></td>
<tr>
<td>State*:</td>
<td><?php if (isset($errors['state'])){echo $errors['state'];} ?><input type="text" name="state" value="<?php echo $formVars['state']; ?>"><br></td>
<tr>
<td>Phone Number*:</td>
<td><?php if (isset($errors['areacode'])){echo $errors['areacode'];} ?><?php if (isset($errors['firstnumber'])){echo $errors['firstnumber'];} ?><?php if (isset($errors['secondnumber'])){echo $errors['secondnumber'];} ?><input type="text" maxlength="3" size="3" name="areacode" value="<?php echo $formVars['areacode']; ?>">-
<input type="text" maxlength="3" size="3" name="firstnumber" value="<?php echo $formVars['firstnumber']; ?>">-
<input type="text" maxlength="4" size="4" name="secondnumber" value="<?php echo $formVars['secondnumber']; ?>"><br></td>
<tr>
<td>Email Address:</td>
<td><input type="text" name="email" value="<?php echo $formVars['email']; ?>"><br></td>
<tr>
<td>Pastor's Name:</td>
<td><input type="text" name="pastor" value="<?php echo $formVars['pastor']; ?>"><br></td>
<tr>
<td>Church Name:</td>
<td><input type="text" name="church" value="<?php echo $formVars['church']; ?>"><br></td>
<tr>
<td>Major Interested In:</td>
<td><select name="major">
<option value="Pastoral Theology - Language Emphasis">4 Year - Pastoral Theology - Language Emphasis
<option value="Pastoral Theology - Non-Language Emphasis">4 Year - Pastoral Theology - Non-Language Emphasis
<option value="Pastoral Theology - Evangelism Emphasis">4 Year - Pastoral Theology - Evangelism Emphasis
<option value="Pastoral Theology - Youth Ministry Emphasis">4 Year - Pastoral Theology - Youth Ministry Emphasis
<option value="Church Ministries for Men">4 Year - Church Ministries for Men
<option value="Church Ministries for Women">4 Year - Church Ministries for Women
<option value="Church Ministries for Men - with a Music Minor">4 Year - Church Ministries for Men - with a Music Minor
<option value="Church Ministries for Men - with a Music Minor">4 Year - Church Ministries for Men - with a Music Minor
<option value="Missiology">4 Year - Missiology
<option value="Christian Elementary Education">4 Year - Christian Elementary Education
<option value="Christian Elementary Education - Special Education Minor">4 Year - Christian Elementary Education - Special Education minor
<option value="Christian Secondary Education: English)">4 Year - Christian Secondary Education: English
<option value="Christian Secondary Education: History">4 Year - Christian Secondary Education: History
<option value="Christian Secondary Education: Mathematics">4 Year - Christian Secondary Education: Mathematics
<option value="Christian Secondary Education: Science">4 Year - Christian Secondary Education: Science
<option value="Church/Christian School Music">4 Year - Church/Christian School Music
<option value="Church Secretarial Science (2 Year Major)">2 Year - Church Secretarial Science
<option value="Bible Certificate (1 Year Major)">1 Year - Bible Certificate
<option value="Undecided" selected="selected">Undecided
</select><br></td>
<tr>
<td>Graduation Date (mm/yyyy):</td>
<td><input type="text" maxlength="2" size="2" name="month" value="<?php echo $formVars['month']; ?>">-<input type="text" maxlength="4" size="4" name="year" value="<?php echo $formVars['year']; ?>"><br></td>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Send Request"></td>
<tr>
<td> </td>
<td>All fields marked with a * are required.<br></td>
</table>
</form>
Any help on how to make the form and errors appear inside the template would be appreciated. Thank you.