如何忽略 URL 中的查询字符串?

发布于 2024-09-05 19:31:49 字数 309 浏览 8 评论 0原文

你好,我有这样的事情:

if(isset($_POST['btnProm'])){
    $idads = mysql_real_escape_string($_POST['idAds']);
    require_once("adPromFrm.php");  
}

当按下按钮时,会出现一个表单......

当我刷新页面时,表单不会消失,但是当我单击带有查询字符串的链接时(thisPage.php?lang =fr...),表格消失。

我知道我仅在按下按钮时才询问表单,但我如何忽略查询字符串。

Hello I have something like this:

if(isset($_POST['btnProm'])){
    $idads = mysql_real_escape_string($_POST['idAds']);
    require_once("adPromFrm.php");  
}

When a button is pressed, a form will appear....

When i refresh the page, the form doesn't disappear, but when i click a link with a query string (thisPage.php?lang=fr...), the form disappears.

I know i m asking the form only if the button is pressed, but how can i ignore the query string.

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

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

发布评论

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

评论(1

恋你朝朝暮暮 2024-09-12 19:31:49

您可以考虑使用 会话 来实现此行为。会话数据保存在请求之间,因此单击链接不会导致表单消失。

观察:

<input type=submit name=showForm value="Show Form">
<input type=submit name=hideForm value="Hide Form">
<?
session_start();

if ($_REQUEST['showForm'])
   $_SESSION[showForm] = true;

if ($_REQUEST['hideForm'])
   $_SESSION[showForm] = false;

if ($_SESSION['showForm'])
{
    include("form.php");
}

You might consider using sessions for this behavior. Session data is held between requests so clicking links won't cause the form to disappear.

Observe:

<input type=submit name=showForm value="Show Form">
<input type=submit name=hideForm value="Hide Form">
<?
session_start();

if ($_REQUEST['showForm'])
   $_SESSION[showForm] = true;

if ($_REQUEST['hideForm'])
   $_SESSION[showForm] = false;

if ($_SESSION['showForm'])
{
    include("form.php");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文