通过表单将POST数据传递到同一页面上

编程入门 行业动态 更新时间:2024-10-28 12:25:41
本文介绍了通过表单将POST数据传递到同一页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个相当复杂的情况。现在我在网页上有一个表格,要求我的访客的信息。我有一个脚本,允许我获取访问者信息并将其附加到链接。

起初,我有一个redirect.php,它允许我将所有信息附加到链接,并使用标题将用户发送到他们的页面。

然而,我想知道是否有可能将此表单数据发送到同一页面并同时显示用户页面。

我希望我有道理。非常感谢。

解决方案

如果理解你的问题可以用很多方法完成,例如使用基于函数的填充。 一种方法是检查表单是否使用 $ _ POST 发布,或者检查隐藏字段$ _POST ['_ submit']。这看起来很乱,但显示基本的方式。

<?php if(!isset($ _ POST ['_ submit '])){?> < form action =post.phpmethod =post> < input type =submit/> < input name =somevaluetype =text/> < input name =_ submittype =hiddenvalue =_ submit/> < / form> <?php } else { echo htmlspecialchars($ _ POST ['somevalue']); ?> < em>< / em> <?php}? >

您还需要做其他事情来使代码生成准备就绪,如uisng isset 在您检查的字段上,否则如果有人篡改表单,您将失去通知

I have a rather complicated situation. Right now I have a form on a page that asks for my visitor's information. I have a script that allows me to take the visitors information and append it to a link.

At first, I had a redirect.php that allowed me to append all the information to the link and used a header to send the user to their page.

However, I was wondering if it is possible to send this form data into the same page AND display the users page at the same time.

I'm hoping I make sense. Thanks a lot.

解决方案

this if understand your question can be done many ways, eg using function based fillers. One way is to check if the form has been posted using $_POST or by checking for a hidden field $_POST['_submit']. this looks messy but shows basic way.

<?php if (!isset($_POST['_submit'])) { ?> <form action="post.php" method="post"> <input type="submit" /> <input name="somevalue" type="text" /> <input name="_submit" type="hidden" value="_submit" /> </form> <?php } else { echo htmlspecialchars($_POST['somevalue']); ?> <em></em> <?php } ? >

There are other things that you would still need to do to make this code production ready like uisng isset on fields your checking against else you will have losts of notices if people tamper with the form

更多推荐

通过表单将POST数据传递到同一页面上

本文发布于:2023-10-12 00:59:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   面上   数据   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!