繁体   English   中英

无法从Html5 CSS和php表单获取信息

[英]Unable to get informations from a Html5 CSS and php form

我尝试建立一个html5表单并将信息发送到form.php

<h3>Contact Me</h3>
<p></p>
<form method="post" action="form.php">
    <div class="row uniform">
        <div class="6u 12u(xsmall)">
            <input type="text" name="name" id="name" placeholder="Name" />
        </div>
        <div class="6u 12u(xsmall)">
            <input type="email" name="email" id="email" placeholder="Email" />
        </div>
    </div>
    <div class="row uniform">
        <div class="12u">
            <input type="text" name="subject" id="subject" placeholder="Subject" />
        </div>
    </div>
    <div class="row uniform">
        <div class="12u">
            <textarea name="message" id="message" placeholder="Message" rows="6"></textarea>
        </div>
    </div>
    <div class="row uniform">
        <div class="12u">
            <ul class="actions">
                <li>
                    <input type="submit" class="special" value="Send Message" />
                </li>
                <li>
                    <input type="reset" value="Reset Form" />
                </li>
            </ul>
        </div>
    </div>
</form>

在同一地方,我有form.php

<?
if (isset($_POST['name']) && isset($_POST['email'])) {
    echo 'name '.$_POST['name'].' mail '.$_POST['email'];
}
?>

当我单击form.php页面时打开,但是空白。

<?php
if (isset($_POST['name']) && isset($_POST['email'])) {
echo 'name '.$_POST['name'].' mail '.$_POST['email'];
}
?>

我认为您错过了PHP标记的<?php而不是<?

是的,抱歉,现在我可以通过邮件发送。

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: lespizz'; 
$to = 'jim@fdfrdsfg.com'; 
$subject = 'Hello';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
mail ($to, $subject, $body, $from)
?>

您知道如何自动返回index.html吗?

谢谢

使用PHP,您可以使用以下代码重定向到另一个页面:

header("Location: index.html");
die();

但是请注意-只有在之前没有输出的情况下,它才起作用!

或者,如果您必须尽早提供一些输出,则可以只使用Javascript进行重定向:

echo '<script type="text/javascript">
           window.location = "http://www.google.com/"
      </script>';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM