2017-06-01 103 views
0

我试图建立一个PHP表单。但是,它不会发送。PHP表单不发送

HTML(index.html的):

<div class="row"> 
      <div id="Contact" class="container"> 
       <h1>Meer weten?</h1> 
       <h2>Neem vrijblijvend contact op</h2> 
       <div id="ContactBlock"> 
        <form class="contactform" method="post" action="submitform.php"> 
         <div class="FormTop"> 
         <div class="half-left-cf"> 
          <input type="text" id="input-name" name="name" placeholder="Naam (verplicht)"> 
          <input type="text" id="input-email" name="email" placeholder="Email address (verplicht)"> 
          <input type="text" id="input-telnr" name="telnr" placeholder="Telefoonnummer"> 
          </div> 
          <div class="half-right-cf"> 
          <textarea name="message" type="text" id="input-message" name="message" placeholder="Uw bericht"></textarea> 
          </div> 
         </div> 
         <label>*Hoeveel is is 2+2? (Anti-spam)</label> 
         <input name="human" placeholder="Antwoord hier"> 
          <input type="submit" value="Verzenden" id="input-submit"> 
        </form> 
       </div> 
      </div>  

PHP(submitform.php):

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$telnr = $_POST['telnr']; 
$message = $_POST['message']; 
$from = 'From: Contact Form'; 
$to = 'e-mail'; 
$subject = 'Hello'; 
$human = $_POST['human']; 

$body = "Afkomstig van: $name\n E-Mail: $email\n Telnr:\n $telnr Bericht:\n $message"; 
if ($_POST['submit']) { 
if ($name != '' && $email != '') { 
    if ($human == '4') {     
     if (mail ($to, $subject, $body, $from)) { 
     echo '<p>Uw bericht werd goed verzonden. Wij contacteren u zo snel mogelijk.</p>'; 
    } else { 
     echo '<p>Er is iets misgegaan, probeer a.u.b. opnieuw!</p>'; 
    } 
} else if ($_POST['submit'] && $human != '4') { 
    echo '<p>U heeft de anti-spam vraag niet correct ingevuld</p>'; 
} 
} else { 
    echo '<p>U heeft niet alle verplichte velden ingevuld</p>'; 
} 
} 
?> 

当我按下提交的浏览器返回相思页面/ .. ./submitform.php在url-bar中。

这种情况都发生在在线环境以及本地主机上。

我做错了什么?谢谢

+0

其中位于你的文件吗? – ImAtWar

+0

这是因为您的操作正在将浏览器发送到该页面,所以在这种情况下它将转到submitform.php,但您的文件结构如何设置 – clearshot66

+0

我的submitform.php文件与index.html位于相同的地图if这就是你要问的。对不起,我真的很新,我一直在寻找几个小时,但似乎无法解决它:-) – BjornsBot

回答

0

如果你不确定你的文件夹结构只是使用这个简单的技巧。

变更后的网址,以绝对的喜欢http://www.example.com/xyz/submitform.php

在当地

http://www.localhost/xyz/submitform.php

而不是试图简单submitform.php