Posted: Tue Feb 15, 2005 3:37 am
Hi,
Thanks for getting back.
If the fields are blank
Show ‘form’
if fields are filled and validate ok
don’t show form show thank you
If you copy and paste the complete code below you will see what is happening. If all the fields are correctly filled in the page submits but all the remaining code gets terminated ie the “Hi I should still see this after the form is submitted!” bit of text should still be there after I submit. This is the bit that is driving me nutters!
Thanks for your patience with me on this.
Brian
Thanks for getting back.
You see what I was really trying to do is have this all on one page and not use a second page at all. For example“I think basiclly you want that lost_name along with a bunch of variables (just guessing, since you haven't showed the mail sending part) accessible on the second thank-you page.”
If the fields are blank
Show ‘form’
if fields are filled and validate ok
don’t show form show thank you
If you copy and paste the complete code below you will see what is happening. If all the fields are correctly filled in the page submits but all the remaining code gets terminated ie the “Hi I should still see this after the form is submitted!” bit of text should still be there after I submit. This is the bit that is driving me nutters!
Thanks for your patience with me on this.
Brian
Code: Select all
<?PHP
// Test whether the POST array has been set and makes certain
// variables are initialzed with no content.
$pattern = '/^\wї-.\w]*@(ї-a-z0-9]+\.)+їa-z]{2,4}$/i';
if ($_POST && array_key_exists('sendCom',$_POST)) {
$nomessage='';
$error=array();
$error_email=array();
$message='';
$lost_email= $_POSTї'lost_email'];
// Check each field and build errors array if problems found
if (isset($_POSTї'lost_email']) && !empty($_POSTї'lost_email'])) {
$message=strip_tags($_POSTї'lost_email']);
}
else {
$nomessage = 'Email Required';
}
if (isset($_POSTї'lost_name']) && !empty($_POSTї'lost_name'])) {
$lost_name=trim($_POSTї'lost_name']);
}
else {
$errorї'lost_name'] = 'Name Required';
}
if (empty($_POSTї'lost_email'])) {// validation of email if inserted otherwise ignore
} else {
if (!preg_match($pattern,$lost_email)) $error_emailї'invalid'] = 'ERROR! Your email address seems to be invalid. <br> It should be similar to the following: info@me.com';
}
// If no errors, send email and redirect to acknowledgment page
if (!$nomessage && !$error) {
if (!$nomessage && !$error_email){
//mail($to,$subject,$message,$additional_headers);
if (isset($error_email) && empty($error_email)) {
if (!empty($_POSTї'lost_email']) && !empty($_POSTї'lost_name'])) {
echo "Thank you" . ' ' .$_POSTї'lost_name'] .',' . ' '."your message was successfully sent";
exit();
//Otherwise, display the form to user
}}}}}?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title> </title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" class="tbl_outer" id="tbl_outer"><tr><td class="mainContent">
</td>
</tr>
<tr>
<td id="error"><?php
if (isset($error_email)) {
foreach ($error_email as $key => $value) {
echo $value.'<br />';
}
}
?></td>
</tr>
<tr>
<td><form method="post" name="form1" action="<?php $_SERVERї'PHP_SELF']?>">
<table>
<tr valign="baseline">
<td align="right" nowrap class="error" id="error">* Name: <br>
<?php
if (isset($error)) { // Display error messages. Otherwise skip table row.
// Loop through error messages and display
foreach ($error as $key => $value) {
echo $value.'<br />';
}
}
?></td>
<td><input type="text" name="lost_name" id="" size="32" value="<?php if (isset($_POSTї'lost_name'])) echo $_POSTї'lost_name'];?>" ></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="error" id="error"> Membership number (if known):<br></td>
<td><input type="text" name="lost_membership_no" id="lost_membership_no" size="32" value="<?php if (isset($_POSTї'lost_membership_no'])) echo $_POSTї'lost_membership_no'];?>" ></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">*Email Address:
<?php if (isset($nomessage) && !empty($nomessage)) {
echo $nomessage; } else {
} ?>
</td>
<td><input type="text" name="lost_email" id="lost_email" value="<?php if (isset($_POSTї'lost_email'])) echo $_POSTї'lost_email'];?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">* Required Field </td>
<td><input name="sendCom" type="submit" id="sendCom" value="Post Message" />
<input name="Reset" type="reset" value="Reset"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p></td>
</tr>
</table>
Hi I should still see this after the form is submitted!
</body>
</html>