Jump to content

Mail/Contact Form error.


flatrabbit

Recommended Posts

Hello,

 

I'm having trouble with mail/contact script from a template I purchased. Thanks for your help in advance. Cheers.

 

SP

 

The Link:

http://brand32.com/clients/erin_partridge/contact.php

 

The error:

Parse error: parse error, unexpected '!' in /home/content/b/r/a/brand32/html/clients/erin_partridge/sendmail.php on line 63

 

The code:

<?php

$error = false;

 

$the_name = $_POST['stname'];

$the_email = $_POST['stemail'];

$the_website = $_POST['stwebsite'];

$the_message = $_POST['stmessage'];

 

 

 

if(!checkmymail($the_email))

{

$error = true;

$the_emailclass = "error";

}else{

$the_emailclass = "valid";

}

 

if($the_name == "")

{

$error = true;

$the_nameclass = "error";

}else{

$the_nameclass = "valid";

}

 

if($the_message == "")

{

$error = true;

$the_messageclass = "error";

}else{

$the_messageclass = "valid";

}

 

if($error == false)

{

$to      =  $_POST['emailreciever'];

$subject = "New Message from " . $_POST['sitename'];

$header  = 'MIME-Version: 1.0' . "\r\n";

$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";

$header .= 'From:'. $_POST['email']  . " \r\n";

 

$message1 = nl2br($_POST['stmessage']);

 

 

$message = "New message from  $the_name <br/>

Mail: $the_email<br />

Website: $the_website <br /><br />

Message: ” . $_POST[‘stmessage’] . “

”;

 

 

if(mail($to,$subject,$message,$header))

{

header( 'Location: contact.php?id=1' ) ;

}

 

}

 

 

 

function checkmymail($mailadresse){

$email_flag=preg_match("!^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$!",$mailadresse);

return $email_flag;

}

 

 

 

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/198292-mailcontact-form-error/
Share on other sites

Not a big regex guy, but I've never seen one begin with an !, someone let me know if this is a valid way to designate negation.

 

$email_flag=preg_match("!^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$!",$mailadresse);

 

try

$email_flag=preg_match("/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/",$mailadresse);

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.