PHP:当我回显错误消息时,表单字段高度发生变化
我正在处理 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我验证表单的页面顶部,我编写了以下要执行的代码:
然后在代码正文中进一步编写了:
通过专门控制警报消息出现的位置,而不仅仅是处理它并在文档头部回显,表单字段高度没有缩小。
谢谢大家的评论。
At the top of my page, where I am validating the form, I wrote the following code to be executed:
Then further down in the body of my code I wrote:
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.