doubeizhong5178 2017-06-01 17:57
浏览 7

Php表格不发送[重复]

This question already has an answer here:

I've tried to built a php form. However, it won't send.

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
 E-Mail: $email
 Telnr:
 $telnr Bericht:
 $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>';
} 
} 
?>

When I press submit the browser returns a blanc page with /.../submitform.php in the url-bar.

This happens both in an online environment as well as on localhost.

Am I doing something wrong? Thanks

</div>
  • 写回答

1条回答 默认 最新

  • drv16759 2017-06-01 18:12
    关注

    If you not sure about your folder structure just use this simple trick.

    Change post url to absolute one like http://www.example.com/xyz/submitform.php

    In local

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

    Instead of trying simple submitform.php

    评论

报告相同问题?

悬赏问题

  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测