Hi I have some problems with a form I am creating and I need some help. If a field is left blank it is supposed to go to a page saying the field and have a javascript:history.back button it doesn't load it. It just displays the page with the error. Can someone take a look and see what I am doing wrong.
Thanks for your help.
Coding
.........................................................................................................
<?php
$y_name = "Support";
$y_email = "you@some.com";
$autor = "yes";
$autor_mail = "Thank you for contacting US.
This is an autogenerated email. Please do not respond to this.
This is to inform you that we have recieved a report of a problem that you are incountering.
A service tech is going to be correcting the problem shortly.
You will be notified whe the problem has been corrected.
Thank You
Support";
$autor_subject = "Thank you for contacting US.";
$after = "thank.htm";
$rfields = "name,email,message";
if (isset($sent)) {
if (!$rfields == "") {
$rfields = explode(",", $rfields);
for($i = 0; $i < count($rfields); $i++) {
if ($$rfields[$i] == "") {
echo "You have not filled in the required field <b>$rfields[$i]</b>. Please click <a href=\"javascript:history.go(-1)\">here</a> to go back and fill in the required field. Thank You.";
exit;
}
}
}
if (!ereg('[-!#$%&\'*+\./0-9=?A-Z_`a-z{|}~]+'.
'@'.
'[-!#$%&\'*+\/0-9=?A-Z_`a-z{|}~]+.'.
'[-!#$%&\'*+\./0-9=?A-Z_`a-z{|}~]+$', $email)) {
echo "Your email, $email, is not valid. Please click <a href=\"javascript:history.back()\">here</a> to fill in a proper email. Thank You.";
exit;
}
$fmail = "$y_name, you have received an email form.\n\n";
$fmail.= "IP Address: $REMOTE_ADDR\n";
$fields = array_keys($HTTP_POST_VARS);
for($i = 0; $i < count($fields); $i++) {
$temp = $fields[$i];
if ($temp == "rfields" || $temp == "submit" || $temp == "sent" || $temp == "y_name" || $temp == "y_email" || $temp == "autor" || $temp == "autor_message" || $temp == "$autor_mail" || $temp == "$autor_subject" || $temp == "after")
$fmail = $fmail;
else {
$temp1 = stripslashes($HTTP_POST_VARS[$temp]);
$fmail.= "$temp: $temp1\n";
}
}
$fmail.= "\nThank you for using US (http://someone.com)";
$mailed = mail($y_email, "Email Form", $fmail, "From: $name <$email>");
if ($autor == "yes")
{
$autor_subject = stripslashes($autor_subject);
$autor_mail = stripslashes($autor_mail);
mail($email, $autor_subject, $autor_mail, "From: $y_name <$y_email>");
}
if(!$mailed) {
echo "There is something wrong with the script or the configuration. Please contact <a href=\"mailto:$y_email\"></a>";
}
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">";
} else {
?>
<HTML>
<HEAD>
<HEAD>
<HTML>
<?
}
?>
.........................................................................................................