简体   繁体   English

由于... CSS,PHP邮件表单文本框无法编辑?

[英]PHP mail form text boxes uneditable due to …CSS?

I've never had this problem before but I'm hoping someone else has. 我以前从未遇到过这个问题,但我希望其他人也有。 I have a php mail script that will not work on my page. 我有一个PHP邮件脚本,无法在我的页面上使用。 It won't even let you type text into the text boxes. 它甚至不允许您在文本框中输入文本。 One of the options is a choice and you can't even make the dropdown work.The entire thing is totally uneditable. 选项之一是选择,您甚至无法使下拉菜单起作用。整个过程完全不可编辑。

I can take the same exact code and put it in a bare bones HTML file and it all works just find. 我可以采用完全相同的代码,然后将其放入裸露的HTML文件中,所有这些都可以找到。 Sends mail correctly, everything just as it should. 正确发送邮件,一切正常。

So evidently there is something either on my webpage or in my CSS file that is totally killing the HTML form, rendering it useless. 因此,很明显,我的网页上或CSS文件中都有某些内容完全杀死了HTML表单,使它毫无用处。

Here is the form code: 这是表单代码:

<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>

Here is the php script: 这是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();
}
?>

I can post the CSS if I need to. 如果需要,我可以发布CSS。 Has anyone ever heard of a mail form doing this? 有人听说过这样做的邮件吗?

Here are the links to the pages if it helps. 如果有帮助,请访问以下页面链接。

This is the bare bones page that the form works fine on: Working test page 这是表单可以正常运行的基础页面工作测试页面

This is my contact page that I'm trying to get it to work on and it won't: non-working actual page 这是我正在尝试使其工作的联系页面,但不会: 无效的实际页面

At this point I'd appreciate any info as I've been banging against this wall since Thursday night and my head hurts...LOL 自从星期四晚上以来我一直在撞墙,我的头好痛,这时我将不胜感激。

You need to clear the floats from your containers... 您需要清除容器中的浮子...

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

Modern browsers have incorporated tools that allow you to inspect what is going on with the HTML and CSS. 现代浏览器已合并了一些工具,可让您检查HTML和CSS的状况。 In Chrome it's View > Developer > Developer Tools. 在Chrome中,依次点击视图>开发人员>开发人员工具。 Firebug is a nice plugin for Firefox and Opera has Dragonfly. Firebug是Firefox的一个不错的插件,Opera具有Dragonfly。 With these tools it takes 3 seconds to find the problem (your bottom container was obstructing the form), with this information it's easier to solve any rendering problems. 使用这些工具,需要3秒才能发现问题(您的底部容器阻碍了表单),有了这些信息,可以更轻松地解决任何渲染问题。

Adding display: inline-block; 添加display: inline-block; to the <div class="container"> makes it editable. <div class="container">使其可编辑。 So I believe you could say it was uneditable due to CSS... Really don't know why, though. 因此,我相信您可以说由于CSS而无法编辑...真的不知道为什么。

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

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