删除PHP电子邮件验证

时间:2018-01-27 12:25:36

标签: php css

如何删除PHP导致的丑陋错误?我不知道webhost是否导致它或者我是否可以使用PHP / CSS修复它,我的代码中没有电子邮件验证The error

  <div class="row">
      <div class="row">
        <div class="input-field col s6">
          <input id="email" type="email" class="validate" name="email">
          <label for="email" data-error="Geen geldig e-mailadres" data-success="Dit e-mailadres word alleen gebruikt om een antwoord te versturen.">Email</label>
        </div>
      </div>
  </div>


<?php
error_reporting(0);
$errors = '';
$myemail = 'my@mail.com';
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['message']))
{
    $errors .= "/n fill in all fields";
}

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

if( empty($errors))

{

$to = $myemail;

$email_subject = "Contact form submission: $name";

$email_body = "You have received a new message. ".

" Here are the details:\n Name: $name \n ".

"Email: $email_address\n Message \n $message";

$headers = "From: $myemail\n";

$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);

//redirect to the 'thank you' page

header('Location: bedankt.html');

}
?>

</body>
</html>

这是电子邮件部分的完整代码,error_reporting(0);似乎不适用于所描述的问题

2 个答案:

答案 0 :(得分:1)

更改您的Html电子邮件

来自

<input type="email" >

<input type="text" >

答案 1 :(得分:0)

正如我评论的那样,将邮件类型更改为HTML中的文本将删除验证。您提到要将字段类型保留为电子邮件。要禁用HTML5验证,您需要在表单中添加novalidate

如:

<form method="post" action="/yourAction" novalidate>...</form>

Reference