Jump to content

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 = "cmf.lhp@gmail.com";
$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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.