PHP:当我回显错误消息时,表单字段高度发生变化

发布于 2024-12-12 18:39:00 字数 498 浏览 2 评论 0原文

我正在处理 html 标题之前的页面顶部的表单:

if ($_POST['submit']) {--the code--}

如果该人输入了错误的代码,则执行以下 php:

echo "<div class=\"container alert-message warning\"><strong>Oops!</strong> The code you entered is incorrect.</div>";

这有效,上面的 div 出现在页面顶部,因为它应该(在主体标签顶部)。然而,我的表单字段的高度缩小到原始高度的一半左右。

我注意到,当警告消息在正文标记的顶部回显时,标题中的所有代码也会在正文中的正下方回显(元、标题、脚本、样式表)。我假设标题信息的回显可能会扰乱表单。

关于为什么会回显标题信息、为什么表单字段高度会改变和/或如何修复其中任何一个的想法?

I am processing a form at the top of my page before the html header and all:

if ($_POST['submit']) {--the code--}

If the person enters the wrong code the following php is executed:

echo "<div class=\"container alert-message warning\"><strong>Oops!</strong> The code you entered is incorrect.</div>";

This works and the div above appears at the top of the page as it should (at the top of the body tag). However, the height of my form fields shrink to about half their original height.

I have noticed that when the warning message is echoed at the top of the body tag, all of the code from my header is also echoed just below it in the body (meta, title, scripts, stylesheets). I'm assuming this echoing of the header info probably is messing with the form.

Any thoughts on why the header info is being echoed, why the form field height is changing, and/or how to fix either?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尹雨沫 2024-12-19 18:39:00

在我验证表单的页面顶部,我编写了以下要执行的代码:

$wrongcode = true;

然后在代码正文中进一步编写了:

if ($wrongcode == 'true')
   echo "<div class=\"container alert-message warning\"><strong>Oops!</strong> The code you entered is incorrect.</div>";

通过专门控制警报消息出现的位置,而不仅仅是处理它并在文档头部回显,表单字段高度没有缩小。

谢谢大家的评论。

At the top of my page, where I am validating the form, I wrote the following code to be executed:

$wrongcode = true;

Then further down in the body of my code I wrote:

if ($wrongcode == 'true')
   echo "<div class=\"container alert-message warning\"><strong>Oops!</strong> The code you entered is incorrect.</div>";

By controlling specifically where the alert message would appear and not just having it process and echo in the head of the document, the form field heights didn't shrink.

Thank you everyone for your comments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文