hello am having problems with PHP script, i’m trying to do a feedback page for a website using the php mail function but i also want to pick up errors on the page i.e. the user is required to enter data into all fields and i’m wanting to make them a regualr expression.
my problem is i can get it to check for the errors but the form does not email the data.
i have done echo statements near the mail() function call and they print out to screen however it doesnt work.
so what i have done temporially is revert to my old code which submits the data but doesnt do error checking.
i have posted new and old data if anyone can point out my mistake it would greatly be appreicated.
code which i cant get to work does error checking my means of putting red astrirks to areas which require a response
<?
$arrErrors = array();
if (!empty($_POST[‘Submit’]))
{
$sendform = true;
//contact details
if($_POST[‘name’]==”)
$arrErrors[‘name’]= ‘*’;
if($_POST[’email’]==”)
$arrErrors[’email’]= ‘*’;
if($_POST[‘occupation’]==”)
$arrErrors[‘occupation’]= ‘*’;
//vehicle information experssions
if($_POST[‘make’]==”)
$arrErrors[‘make’]= ‘*’;
if($_POST[‘model’]==”)
$arrErrors[‘model’]= ‘*’;
if($_POST[‘year’]==”)
$arrErrors[‘year’]= ‘*’;
if($_POST[‘engine’]==”)
$arrErrors[‘engine’]= ‘*’;
//Question infromation experssions
if($_POST[‘question1’]==”)
$arrErrors[‘question1’]= ‘*’;
if($_POST[‘question2’]==”)
$arrErrors[‘question2’]= ‘*’;
if($_POST[‘question3’]==”)
$arrErrors[‘question3’]= ‘*’;
if($_POST[‘question4’]==”)
$arrErrors[‘question4’]= ‘*’;
if($_POST[‘question5’]==”)
$arrErrors[‘question5’]= ‘*’;
if($_POST[‘question6’]==”)
$arrErrors[‘question6’]= ‘*’;
if($_POST[‘question7’]==”)
$arrErrors[‘question7’]= ‘*’;
if (count($arrErrors) >= 1) {
$strError = ‘Please check the following fields with red astrik (*) and try again:’;
}
//$sendform == true;
else if($sendform==true) {
// If the error array is empty, there were no errors.
// Insert form processing here.
$headers = “From: “.$name.”<“.$email.”>nReply-website”;
//$message =”Persons Contact Details”
//Response in email message.
//contact detail information
$message =”From :$namen”;
$message .=”Email Address :$emailn”;
$message .=”Contact Details :$contact_detailsn”;
$message .=”Occupation :$occupationn”;
//vehicle information
$message .=”Make :$maken”;
$message .=”Model :$modeln”;
$message .=”Year :$yearn”;
$message .=”Engine :$enginen”;
//Question information
[COLOR=Red]took out most of the questions
[COLOR=Blue]Have put in echo statement before and after the issent= mail( $recpient…………..) however still doest not work
$issent = mail($recipient, $subject, $message, $headers);
echo “thankyou for your time everything has been submitted”;
}
}
?>
current code which submits everything but doenst do appropiate checking i think the reason why the code that does not submit everything may have something to do with this code below i.e the while loop
<?
$sendform = false;
if(isset($_POST[‘Submit’])){
while(list($key,$val) = each($
$$key = $val;
if($val!=”) $sendform = true;
}
//regular experssions
if((!eregi(“^[_..
echo “<span class=”style17”>Invalid type email address! i.e. [email][email protected]
//contact details
if(empty($name)){echo(“No Name Entered, please enter<br />”);}
if(empty($email)){echo(“No E-Mail Entered, please enter<br />”);}
if(empty($occupation)){echo(“No Occupation Entered, please enter<br />”);}
//vehicle information experssions
}
else if($sendform==true) {
$headers = “From: “.$name.”<“.$email.”>nReply-
//$message =”Persons Contact Details”
//Response in email message.
//contact detail information
[COLOR=Red]Note: Code has been simplified
$issent = mail($recipient, $subject, $message, $headers);
if(isset($issent)) echo “<span class=”newstime”>Thank you for your time</span>”;
} else echo “<span class=”newstime”>All fields must be filled in. Unable to send form.</span>”;
}
?>
if anyone can help it would greatly be appreicated
cheers
James