dongzice4895 2013-02-20 11:48
浏览 30
已采纳

继续收到“无效的电子邮件”[关闭]

I keep getting invalid email. Please help! I am new to forms. I have a form in html action is send info to this php. ot sure what the problem is but does it matter if there is two email validation? I have this php page and a jQuery, both validating the email. not sure if that is the affecting this.

<?php 
$errors = '';
$myemail = 'something@something.com';
if(empty($_POST['contact_name'])  || 
   empty($_POST['contact_email']) || 
   empty($_POST['contactcomment']))
{
    $errors .= "
 Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if(filter_var($email_address,FILTER_VALIDATE_EMAIL) === false)
{
    echo 'Email is not valid';
}
else
{

} 
  • 写回答

3条回答 默认 最新

  • dongyou1926 2013-02-20 11:51
    关注

    You're checking to see if $_POST['contact_email'] is empty but passing the value of $_POST['email'] to $email_address, I'm assuming that contact_email is the one you want since that is the one you're checking to see if its empty or not. So email will either be empty or something@something none of which is a valid email.

    So simply change:

    $email_address = $_POST['email']; 
    

    to:

    $email_address = $_POST['contact_email']; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端