dongpa9277
dongpa9277
2012-06-02 07:28

Jem的免费PHP邮件表单(语法错误)[关闭]

已采纳

I am trying to use This PHP Mail form,

http://jemsmailform.com/

and I keep getting syntax errors on 2 different lines. Line 70, and 72.

This is what is on those lines.

if (isset($requiredFields['name']) && !empty($_POST['name']) !preg_match("/^[a-  zA-Z-'\s]*$/", stripslashes($_POST['name'])))
    $error_msg .= "The name field must not contain special characters.
";

if (isset($requiredFields['email']) && !empty($_POST['email'] && !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email'])))
    $error_msg .= "That is not a valid e-mail address.
";

Checking this file against a PHP syntax checker here.

http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/v5-3/syntax-check.php

first it said: unexpected '!'

Then I removed the '!' and rechecked, it showed "unexpected T_BOOLEAN_AND, expecting ')'"

So I am a little lost, Not quite sure how I can configure this correctly. I dont really mind if the Name Checker doesn't work, but its the Email validator that I care about. Because you could write: "Email: Gorilla" or something and it would send to my email. So to prevent random spam and useless contact information, I would prefer the email to pass validation.

I am a bit new to PHP, so I am not quite sure where I should go from here, Any thoughts anyone? Id appreciate the help.

Take care folks!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doulu8341 doulu8341 9年前

    You missed another && in the first line and on the second if, you missed to close the ) after your empty:

    if (isset($requiredFields['name']) && !empty($_POST['name']) && !preg_match("/^[a-  zA-Z-'\s]*$/", stripslashes($_POST['name'])))
        $error_msg .= "The name field must not contain special characters.
    ";
    
    if (isset($requiredFields['email']) && !empty($_POST['email']) && !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email'])))
        $error_msg .= "That is not a valid e-mail address.
    ";
    
    点赞 评论 复制链接分享

相关推荐