- Messages
- 1,570
- Name
- Brian
- Edit My Images
- Yes
Any scripting guru's out there that may be able to help with a script on my contact form.
I want the page to automatically go to the index page after a message has been sent, after the "thank you" bit.
Also, (I don't ask for much do I) cough cough:nuts:, if someone doesn't enter their email address they get a message telling them, is there a way to get the page to go back to the form?
Thank you in anticipation.
The code I use at the moment is:
I want the page to automatically go to the index page after a message has been sent, after the "thank you" bit.
Also, (I don't ask for much do I) cough cough:nuts:, if someone doesn't enter their email address they get a message telling them, is there a way to get the page to go back to the form?
Thank you in anticipation.
The code I use at the moment is:
<?php
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered, please use the back button on your browser to correct";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "bt@durhamcitystudios.com";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Thank you, we will be in touch soon!';
} else {
echo 'ERROR!';
}
}
?>