dongpa9277 2012-06-02 07:28
浏览 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 2012-06-02 07:31
    关注

    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.
    ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog