0

我以前从未遇到过这个问题,但我希望其他人有。我有一个无法在我的页面上运行的 php 邮件脚本。它甚至不允许您在文本框中输入文本。其中一个选项是一个选择,您甚至无法使下拉菜单起作用。整个事情是完全不可编辑的。

我可以采用相同的确切代码并将其放入一个简单的 HTML 文件中,一切都可以找到。正确发送邮件,一切正常。

很明显,我的网页或 CSS 文件中的某些内容完全扼杀了 HTML 表单,使其无用。

这是表单代码:

<form action="contact.php" method="post">
    <table>
        <tr>
            <td><b>Your Name:</b></td>
            <td> <input type="text" name="yourname" /></td>
        </tr>
        <tr>
            <td><b>Subject:</b> </td>
            <td><select name="subject" />
                <option value=""> -- Please select -- </option>
                <option>Prayer Requests</option>
                <option>Praise Report</option>
                <option>General Feedback</option>
            </select></td>
        </tr>
        <tr>
            <td><b>E-mail:</b> </td>
            <td><input type="text" name="email" /></td>
        </tr>
        <tr>
            <td><b>Your comments:</b></td>
            <td><textarea name="comments" rows="10" cols="40"></textarea><td></tr></td>
        <tr>
            <td><input type="submit" value="Send it!"></td>
        </tr>
    </table>
</form>

这是php脚本:

<?php
/* Set e-mail recipient */
$myemail  = "feedback@the-ecclesia.org";

/* Check all form inputs using check_input function */
$yourname = check_input($_POST['yourname'], "Enter your name");
$subject  = check_input($_POST['subject'], "Write a subject");
$email    = check_input($_POST['email']);
$website  = check_input($_POST['website']);
$likeit   = check_input($_POST['likeit']);
$comments = check_input($_POST['comments'], "Write your comments");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
    show_error("E-mail address not valid");
}

/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
    $website = '';
}

/* Let's prepare the message for the e-mail */
$message = "Hello!

Your contact form has been submitted by:

Name: $yourname
E-mail: $email
URL: $website

Comments:
$comments

End of message
";

/* Send the message using mail() function */
mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();

/* Functions we used */
function check_input($data, $problem='')
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0)
    {
        show_error($problem);
    }
    return $data;
}

function show_error($myError)
{
?>

<html>
    <body>
        <b>Please correct the following error:</b><br />
        <?php echo $myError; ?>
    </body>
</html>

<?php
exit();
}
?>

如果需要,我可以发布 CSS。有没有人听说过这样的邮件表格?

如果有帮助,这里是指向页面的链接。

这是表单可以正常工作的基本页面: 工作测试页面

这是我试图让它工作的联系页面,但它不会: 非工作实际页面

在这一点上,我会很感激任何信息,因为我从周四晚上就一直在撞墙,我的头很痛……哈哈

4

2 回答 2

3

您需要清除容器中的浮动...

.container {
  width: 980px;
  position: relative;
  margin-left: auto;
  margin-right: auto;
  clear: both;
}

现代浏览器已经集成了允许您检查 HTML 和 CSS 正在发生的事情的工具。在 Chrome 中,它是视图 > 开发人员 > 开发人员工具。Firebug 是一个不错的 Firefox 插件,Opera 有 Dragonfly。使用这些工具可以在 3 秒内找到问题(您的底部容器挡住了表单),使用这些信息可以更轻松地解决任何渲染问题。

于 2012-09-23T02:23:01.147 回答
0

添加display: inline-block;<div class="container">使其可编辑。所以我相信你可以说它是由于 CSS 而无法编辑的……不过,真的不知道为什么。

于 2012-09-23T02:25:39.907 回答