【问题标题】:Redirected to Page with selected url parameter使用选定的 url 参数重定向到页面
【发布时间】:2016-08-20 00:15:16
【问题描述】:

大家好,我有这样的网址页面

http://localhost/skripsi3/web/pesananwaiting.php?pilih=13

表格里面有个按钮,代码是这样的

echo "<a href='considered.php?idorder=" . $row['id_order']."'><button type='button' class='btn btn-primary btn-default btn-sm'>Considered</button></a>";

如果我单击该按钮,它将重定向到考虑的.php。做更新查询,这是我考虑的.php

<?php
session_start();
include "connectdb.php";

$idorder = $_GET["id"];
$cons = "Considered";

$query="UPDATE `preorder` SET `statuspesanan`='$cons' WHERE `id_order`='$_GET[idorder]'";
$result = mysql_query($query);
header("Location:pesananwaiting.php");
?>

我的问题是如何使用这样的参数将标头返回到 pesananwaiting.php

pesananwaiting.php?pilih=13

谢谢

【问题讨论】:

  • 我只是想指出您所考虑的.php 脚本容易受到代码注入的影响。

标签: php mysql url-redirection


【解决方案1】:

您可以通过按钮发送$_GET['pilih']$_GET['idorder']

echo "<a href='considered.php?idorder=" . $row['id_order'] . "&pilih=" . $_GET['pilih'] . "'><button type='button' class='btn btn-primary btn-default btn-sm'>Considered</button></a>";

然后,在pesananwaiting.php 中回显$_GET['pilih']

header("Location:pesananwaiting.php?pilih=" . $_GET['pilih']);

【讨论】:

  • 嘿@luweiqi 非常感谢......它就像一个魅力!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-24
  • 2013-12-16
  • 1970-01-01
  • 2023-03-19
  • 2013-09-12
  • 2020-10-29
相关资源
最近更新 更多