Jump to content

Newbie needs help please


cmf

Recommended Posts

I get this message when hit submit button on my form.

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found

 

It is on a contact form. The email gets sent and I receive, however, I have no idean how to get rid of this message.

Thanks for your help :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/278694-newbie-needs-help-please/
Share on other sites

I hope this is what you need:

 

<?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(preg_match("^[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 = "[email protected]";
$email_subject = "Web Inquiry: ".$_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 'Message sent!'; 
} else {
echo 'ERROR!';
}
}
?>

Thanks cpd; this is my first form using php :)  I have no idea what you mean; correction, I have no idea what i'm doing  :(  I've been reading all day about this issue and am not expecting you to solve my problem (unless you really want to help a grandma LOL)).  Do you mind telling me what I have to change in the above code I posted?  PS you are really cute!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.