I'm trying to validate a form and then send the user to a confirmation page. Here is my code. Obviously my if statement specifying a new action is the wrong approach since it just returns a blank form, I would appreciate some help in reworking my methodology... thanks in advance! Chad
<HTML>
<HEAD>
<TITLE>2007 Conference Exhibitor Registration Form</TITLE>
<SCRIPT TYPE="text/javascript" src=../javascript/formval.js>
</SCRIPT>
<STYLE TYPE="text/css">
@import url(../css/formval.css);
</STYLE>
</HEAD>
<BODY vLink=#0000ff aLink=#0000ff bgColor=#000066 leftMargin=0 topMargin=0>
<?php
if (isset($_POST['posted'])) {
//put the submitted values into regular variables
$firstname = $_POST[firstname];
$lastname = $_POST[lastname];
$organization = $_POST[organization];
$address1 = $_POST[address1];
$city = $_POST[city];
$state = $_POST[state];
$zip = $_POST[zip];
$email = $_POST[email];
function form_validate() {
$error_log = "";
if ($_POST['firstname'] == "") {
$error_log = $error_log . "no firstname entered.<br>";
} //end blank name if
if ($_POST['lastname'] == "") {
$error_log = $error_log . "no lastname entered.<br>";
} //end blank name if
if ($_POST['address1'] == "") {
$error_log = $error_log . "no address entered.<br>";
} //end blank address if
if ($_POST['city'] == "") {
$error_log = $error_log . "no city entered.<br>";
} //end blank city if
if ($_POST['state'] == "") {
$error_log = $error_log . "no state entered.<br>";
} //end blank state if
if ($_POST['zip'] == "") {
$error_log = $error_log . "no zip entered.<br>";
} //end blank zip if
if ($_POST['email'] == "") {
$error_log = $error_log . "no email entered.<br>";
} //end blank email if
//echo "$error_log - inside function<br>";
return $error_log;
} //end form_validate function
$all_errors = form_validate();
global $all_errors;
} //end ifset
//if no errors, proceed to confirmation page
if (($all_errors == "") and (isset($_POST[posted]))) {
echo "<form name='reg_form' action='preprocess.php' method='post' >";
} else {
echo $all_errors;
//return the filled out form to the user and ask them to try again
?>
<form name="reg_form" action="validation.php" method="post" >
<input type="hidden" name="posted" value="true">
<TABLE cellSpacing="0" cellPadding="0" border="0" width="100%">
<TBODY>
<TR>
<TD align="middle" bgColor="#000066" colSpan="4" height="25">
<P style="MARGIN-TOP: 6px; MARGIN-BOTTOM: 6px" align="center">
<img border="0" src="../images/logo_300.gif" width="307" height="85"><br>
<B>
<FONT style="FONT-SIZE: 12pt; FONT-STYLE: italic" face=Arial color=#ffffff>
2007 CONFERENCE REGISTRATION FORM for EXHIBITORS
</FONT>
</B>
</P>
</TD>
</TR>
<tr>
<TD vAlign="top" width="40%" bgColor="#336699" colSpan="4">
<p class="instructionheader">
Important Information
</p>
<p class="instructiontext">
Use this form to register
for the 2007 Conference. When you submit this form, you will get a
confirmation page. Print the page and mail it with your check to the
address shown, or now <B>you can pay with a credit card</B> through our
Paypal account. Please note that once you submit this form, <B>you
will be registered for the conference</B>, and unless cancelled in
accordance with the policy below payment will be required.<br>
<br>
All presenters are required to be
registered and paid conference attendees.
</p>
<NOSCRIPT>
<p>Javascript is not currently enabled on your browser. If you can enable it, your input will be checked as you enter it (on most browsers, at least). You may find this helpful. </p>
</NOSCRIPT>
</TD>
</tr>
<TR>
<TD class="formheader" colSpan="4">
<P class="formheader"><B>Step 1 - </B>Your Information<FONT style="FONT-SIZE: 13pt" face=Wingdings> òòò</FONT></P>
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=firstname>first name:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="1" maxLength="50" size="35" name="firstname" value="<?php echo $firstname; ?>" ONCHANGE="validatePresent(this, 'inf_firstname');">
</TD>
<TD id="inf_firstname" class="formFB">
Required
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=firstname>last name:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="2" maxLength="50" size="35" name="lastname" value="<?php echo $lastname; ?>" ONCHANGE="validatePresent(this, 'inf_lastname');">
</TD>
<TD id="inf_lastname" class="formFB">
Required
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=organization>organization:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="3" maxLength="80" size="35" name="organization" value="<?php echo $organization; ?>">
</TD>
<TD id="inf_organization" class="formFB">
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=address>address:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="4" maxLength="80" size="35" name="address1" value="<?php echo $address1; ?>" ONCHANGE="validatePresent(this, 'inf_address');">
</TD>
<TD id="inf_address" class="formFB">
Required
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=city>city:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="5" maxLength="50" size="35" name="city" value="<?php echo $city; ?>" ONCHANGE="validatePresent(this, 'inf_city');">
</TD>
<TD id="inf_city" class="formFB">
Required
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=state>state:</LABEL>
</TD>
<TD class="formbox">
<SELECT tabIndex="6" name="state" size="1" value="<?php echo $state; ?>" ONCHANGE="validatePresent(this, 'inf_state');">
<OPTION value="">Select State</OPTION>
<OPTION value="AL">Alabama</OPTION>
<OPTION value="AK">Alaska</OPTION>
<OPTION value="AZ">Arizona</OPTION>
<OPTION value="AR">Arkansas</OPTION>
<OPTION value="CA">California</OPTION>
</SELECT>
</TD>
<TD id="inf_state" class="formFB">
Required
</TD>
</TR>
<TR>
<TR>
<TD class="formlabel">
<LABEL FOR=zip>zip:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="7" maxLength="10" size="10" name="zip" value="<?php echo $zip; ?>" ONCHANGE="validatePresent(this, 'inf_zip');">
</TD>
<TD id="inf_zip" class="formFB">
Required
</TD>
</TR>
<TR>
<TR>
<TD class="formlabel">
<LABEL FOR=phone>phone:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="8" maxLength="15" name="phone" size="35" value="<?php echo $phone; ?>">
</TD>
<TD id="inf_phone" class="formFB">
</TD>
</TR>
<TR>
<TD class="formlabel">
<LABEL FOR=email>email:</LABEL>
</TD>
<TD class="formbox">
<INPUT tabIndex="9" maxlength="80" size="35" name="email" value="<?php echo $email; ?>" ONCHANGE="validateEmail(this, 'inf_email');">
</TD>
<TD id="inf_email" class="formFB">
Required
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor="#c0c0c0" cellSpacing="0"
borderColorDark="#999999" cellPadding="0" borderColorLight="#999999" border="0">
<TBODY>
<TR>
<TD
style="BORDER-RIGHT: medium none; BORDER-TOP: solid; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"
width="100%" bgColor=#000066 colSpan=3>
<P style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 3px; MARGIN-LEFT: 25px"
align=left><FONT face=Arial color=#ffffff><FONT
style="FONT-SIZE: 11pt"><B>Step 2 - </B>Submit your
Registration</FONT></FONT><FONT style="FONT-SIZE: 13pt" face=Wingdings
color=#ffffff> òòò</FONT></P></TD></TR>
<TR>
<TD style="BORDER-TOP: medium none" align=left bgColor=#336699>
<P style="MARGIN: 3px 10px" align=justify>
<FONT style="FONT-SIZE: 9pt" face=Arial color=#ffffff>Be sure to check your information before pressing
the submit button. Optional - you can print this page before submitting it
using the print button. <B>Payment information will be shown on your confirmation page.</B>
After you press Submit Registration, you will have the option of paying your fees
online (using our Paypal account) or with a check by mail.</FONT> </P> </TD>
<TD width="50" align=middle vAlign=center
bgColor=#336699 style="BORDER-TOP: medium none">
<P style="MARGIN-TOP: 10px; MARGIN-BOTTOM: 3px"><FONT face=Arial><SPAN
style="FONT-SIZE: 9pt"><INPUT tabIndex="32" type="submit" value="Submit Registration" name="Submit">
</SPAN></FONT></P>
<P style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 3px"><FONT face=Arial><SPAN
style="FONT-SIZE: 9pt"><INPUT tabIndex="33" type="reset" value=" Reset all Fields " name="Reset">
</SPAN></FONT></P>
<P style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 0px"><FONT
style="FONT-SIZE: 9pt" face=Arial color=#ffffff>
</FONT></P></TD>
</TR>
</TBODY>
</TABLE>
</FORM>
<?php
}
?>
</BODY>
</HTML>