首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >弹出窗口和PHP表单

弹出窗口和PHP表单
EN

Stack Overflow用户
提问于 2013-11-17 01:45:44
回答 2查看 14.9K关注 0票数 0

我已经创建了一个联系人页面和一个单独的PHP页面来接收发布的数据。我想让PHP在弹出窗口中打开。我已经尝试了在线方法,但没有任何成功,我可以使弹出窗口出现,但我不能让PHP发送数据。

<!------Contact Page------->

<form method='post' action='sendemail.php' >
    <label>Name</label>
    <input name="name" placeholder="Type Here">
    <label>Email</label>
    <input name="email" placeholder="Type Here" id="email">
    <label>Message</label>
    <textarea name="message" placeholder="Type Here"></textarea>


    <label>Human Verification</label>
      <input name="human" placeholder="2 + 2 = ? " id="human">
      <input id="submit" name="submit" type="submit" value="Submit">
    </label>     
</form>

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = $email; 
    $to = 'my@email.com'; 
    $subject = 'New Message';
    $human = $_POST['human'];

    $body = "From: $name\n E-Mail: $email\n Message:\n $message";

    if ($_POST['submit']) {
        if ($name != '' && $email != '') {
            if ($human == '4') {                 
                if (mail ($to, $subject, $body, $from)) { 
                    echo '<h4>Your message has been sent!</h4>';
            } else { 
                echo '<h4>Something went wrong, go back and try again!</h4>'; 
            } 
        } else if ($_POST['submit'] && $human != '4') {
            echo '<h4>You answered the anti-spam question incorrectly!</h4>';
            }
        } else {
            echo '<h4>You need to fill in all required fields!!</h4>';
        }
    }
?>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20021667

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档