php中redirect参数中带有id如何解决

在PHP中,如果redirect参数中带有id,可以通过以下几种方式解决:

将id参数拼接到重定向URL中:

$id = $_GET['id'];
header("Location: http://example.com/page.php?id=$id");
exit;

使用urlencode对id进行编码:

$id = $_GET['id'];
$id = urlencode($id);
header("Location: http://example.com/page.php?id=$id");
exit;

将id参数存储在session中,然后在重定向后获取:

$id = $_GET['id'];
session_start();
$_SESSION['id'] = $id;
header("Location: http://example.com/page.php");
exit;

在页面重定向后,可以通过$_SESSION[‘id’]获取之前存储的id参数。

阅读剩余
THE END