HTML/PHP页面结构永久重定向到不同页面
我正在尝试这种网页结构,以我的网站的一部分,但我不知道如何。 这是一个登录用户: 在第1页,用户单击按钮进入第2页 在第2页上,用户执行操作以进入第3页 现在,我要说的是: 在第1页,用户单击按钮进入第3页 (如中所示,最初让他们进入第2页的按钮与之前相同,但由于用户进行了操作,通常会将他们引导至2页的按钮永久性地将他们引导至3页) 具体来说,我需要的帮助是在操作发生后让第1页重新插入第3页,而不是第2页。我该怎么办?我想可能是使用数据库的吧?HTML/PHP页面结构永久重定向到不同页面,php,html,redirect,structure,Php,Html,Redirect,Structure,我正在尝试这种网页结构,以我的网站的一部分,但我不知道如何。 这是一个登录用户: 在第1页,用户单击按钮进入第2页 在第2页上,用户执行操作以进入第3页 现在,我要说的是: 在第1页,用户单击按钮进入第3页 (如中所示,最初让他们进入第2页的按钮与之前相同,但由于用户进行了操作,通常会将他们引导至2页的按钮永久性地将他们引导至3页) 具体来说,我需要的帮助是在操作发生后让第1页重新插入第3页,而不是第2页。我该怎么办?我想可能是使用数据库的吧? 设置会话变量以存储是否已执行操作 表演 按钮的链接
- 设置会话变量以存储是否已执行
表演操作
- 按钮的链接应根据会话动态设置 变数
opertation()
{
//some stuff here
$_SESSION['op_done']=true;
}
在按钮链接中
<a href="<?php
if(isset($_SESSION['op_done']) && $_SESSION['op_done'])
{
echo "link_to_page3";
}
else
{
echo "link_to_page2";
}
?>"> Button_Name
</a>
简而言之,创建一个动态按钮链接,它将根据会话变量进行调整 在这里,您需要在
$\u会话中跟踪用户的状态。让我解释一下
当用户执行操作时,在会话中记录其状态,如下所示:
$_SESSION['operation'] = true;
page1.php
if($_SESSION['operation']){
// user has already completed the operation
// redirect the user to page3.php
header("Location: page3.php");
exit();
}else{
// user didn't complete the operation
// redirect the user to page2.php
header("Location: page2.php");
exit();
}
// when the user completes the operation, redirect the user to page3.php, like this
header("Location: page3.php");
exit();
page2.php
if($_SESSION['operation']){
// user has already completed the operation
// redirect the user to page3.php
header("Location: page3.php");
exit();
}else{
// user didn't complete the operation
// redirect the user to page2.php
header("Location: page2.php");
exit();
}
// when the user completes the operation, redirect the user to page3.php, like this
header("Location: page3.php");
exit();
如果某人未登录,我会使用以下命令重新呼叫他们:session_start();如果(!isset($_SESSION['userid'])| | empty($_SESSION['userid']){die(header(“Location:login.php”));}?>
那么我应该如何修改它以在数据库中获取一个变量并在为真时重定向?@Voken:Dynamic button link应该是您的解决方案。请看编辑。它给出了一个大概的想法。好吧,我想我明白你的意思了。我的一个问题是,如何使按下按钮时操作为真?您可以使用javascript实现这种行为。啊。我以前从未使用过js。你知道这样的指南吗?我想这会对你有帮助,