【问题标题】:Hide ID in PHP/MySQL [closed]在 PHP/MySQL 中隐藏 ID [关闭]
【发布时间】:2016-05-27 06:59:07
【问题描述】:

我正忙于一个网页,以便能够回答问题。我有 2 页用 PHP 编写。

results.php:一个从数据库中获取所有行的while循环,包括。他们的身份证。每个问题都有自己的 ID。

<li><a href="answer.php?id=<?php echo $id;?>">Answer this question: </a></li>

reply.php:这会根据其 id 显示一个问题,但我不想在 $_POST 中显示 id,例如:reply.php?id=1。我试图通过将其放入会话中来隐藏 id,但这不起作用。 有人可以帮帮我吗?

<?php 
if(isset($_POST['answer']))

{

$id = $_GET['id'];
/*


Each id that belongs to its question needs to changed when you click on    another link it has to be looped.

Each time when we click on the answer link, we get the same id constantly but that is not our purpose.

I tried to give in the results.php file to give the id together with the url to avoid SQL Injections.

I placed the ids out of loops and placed it in session. Only the $_SESSION['vid'] stays the same even if I click on another answer link.


*/

}

【问题讨论】:

  • 请发布一个 MCVE,向我们展示您的尝试。 stackoverflow.com/help/mcve
  • 如果你使用 $_POST ,它不会显示 URL 中的数据,

标签: php mysql sql


【解决方案1】:
<Form methode="POST"></form>

将停止显示?id=1。但是您将不再使用$GET[''] 从网址中获取信息。您需要使用$_GET[''] 从网址中获取信息。可以尝试使用php rewrite rule来重写url,这样就不会显示id了。

【讨论】:

    【解决方案2】:

    $_POST[""] 不会在 URL 中显示任何信息。尽管在您的情况下,如果您想在同一页面(例如博客)上发布数据库中的数据,您应该使用$_GET[""]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      • 2013-05-05
      • 2021-04-01
      • 2016-11-10
      相关资源
      最近更新 更多