help with email script...
Posted on
16th Feb 2014 07:03 pm by
admin
hey
I need help with my mail script
when the form on http://www.mcgdesignstudio.com/contact.html is filled out, it send the from with no errors.. however i never receive it..
my hosting company have told me as long as i have the fourth element in if -f or something it will work, dunno where to put that though..
this is my script:
Code: <?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";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "martin@mcgdesignstudio.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 'You need to fill in all the required fields...'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."n";
}
}
if(mail("$your_email", "$email_subject", "$email_content",
"To: Martin Greenwood <$your_email >n" .
"From: mcgdesignstudio.com <martin@mcgdesignstudio.com>n" .
"MIME-Version: 1.0n" .
"Content-type: text/html; charset=iso-8859-1"
)){
echo 'Your message has been sent successfully..';
} else {
echo 'Oops, something went wrong...try again later.';
}
}
?>
No comments posted yet
Your Answer:
Login to answer
136
52
Other forums
Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree
Multipe Dynamic Controls & AutoPostback Issue
I currently have a need to create many dynamic controls (Example Textboxes) that need to do a PostBa
bit of help needed
Im about to sort out my registration page for my website by customising a "registration" s
TCP Sending Unsigned Char...
Hi...
I want to send over tcp/ip some data, i have the data in hexadecimal, and when i tr
An odd assignment statement. Can someone explain this assignment to me?
What purpose is served by the bit of code between the two equal signs in the $installurl set? Is th
Need to write a cookie with a url var
Not sure if its possible, but I need to write a cookie with a url.
So this would write 2232 a
extract a file from zip file
hi,
i know how to unzip a zip file in php, but is there a way to just extract a certain file only
Edit MySQL Row Using PHP and HTML Form
Hello,
Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.
'grab_files', multiple extension?
hey guys,
can anyone suggest a way to make to following line of code look for files with more
weeks in a year
hi,
i found this snippet on php.net
QuoteFor the week number for weeks starting on Sunday: