flatrabbit Posted April 12, 2010 Share Posted April 12, 2010 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/198292-mailcontact-form-error/ Share on other sites More sharing options...
andrewgauger Posted April 12, 2010 Share Posted April 12, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/198292-mailcontact-form-error/#findComment-1040478 Share on other sites More sharing options...
flatrabbit Posted April 12, 2010 Author Share Posted April 12, 2010 Thanks Andrew, but no dice. Still getting the error. Quote Link to comment https://forums.phpfreaks.com/topic/198292-mailcontact-form-error/#findComment-1040488 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.