在我被告知查看其他类似的帖子之前,请注意我已尝试应用它们但无济于事。
在一系列 if 语句为真之后,我需要清除 url 中的变量。我有以下代码:
<?php
$_SESSION['passlevel']='0';
if ($_SESSION['passlevel'] == '0')
{
if(isset($_GET['box_1_color']))
{
$color=$_GET['box_1_color'];
if($color == "#800080")
{
echo "you have passed step one.";
$_SESSION['passlevel'] = '1';
// add something that removes url string
}
else
{
echo "you didn't select purple.";
}
}
else echo "login with your colorlock passcode.";
}
if ($_SESSION['passlevel'] == '1')
{
if(isset($_GET['box_1_color']))
{
$color=$_GET['box_1_color'];
if($color == "#DD7500")
{
echo "you have passed step two.";
$_SESSION['passlevel']='2';
// add something that removes url string
}
else
{
echo "you didn't select orange.";
}
}
else echo "enter remaining colors.";
}
?>
这是针对颜色相关的密码,在单击 div 后,10 个 div 中的每一个的背景都会更改为 10 种颜色之一(请注意,一些回声现在仅作为调试方法存在)。信息通过多种形式发送到url:
<form>
<div id="box1" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box1color ?>'/>
<input type='hidden' name='name' value='box1color'/>
</form>
<form>
<div id="box2" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box2color ?>'/>
<input type='hidden' name='name' value='box2color'/>
</form>
<form>
<div id="box3" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box3color ?>'/>
<input type='hidden' name='name' value='box3color'/>
</form>
<form>
<div id="box4" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box4color ?>'/>
<input type='hidden' name='name' value='box4color'/>
</form>
<form>
<div id="box5" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box5color ?>'/>
<input type='hidden' name='name' value='box5color'/>
</form>
<form>
<div id="box6" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box6color ?>'/>
<input type='hidden' name='name' value='box6color'/>
</form>
<form>
<div id="box7" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box7color ?>'/>
<input type='hidden' name='name' value='box7color'/>
</form>
<form>
<div id="box8" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box8color ?>'/>
<input type='hidden' name='name' value='box8color'/>
</form>
<form>
<div id="box9" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box9color ?>'/>
<input type='hidden' name='name' value='box9color'/>
</form>
<form>
<div id="box10" class="box" onclick='this.parentNode.submit()'></div>
<input type='hidden' name='box_1_color' value='<?php echo $box10color ?>'/>
<input type='hidden' name='name' value='box10color'/>
</form>
选择其中一种颜色(紫色)后的 url 示例:
http://localhost/colorlock/index.php?box_1_color=%23800080&name=box9color
所以我想删除 ?box_1_color=%23800080&name=box9color 部分。我怎么能在代码说“//添加一些删除url字符串的东西”的地方删除它,以便在启动下一个代码块时它不会立即在url中使用相同的颜色代码运行,然后用户才能选择他们的下一个颜色?
我希望我的问题很清楚(我知道这很令人困惑),我希望它是可以回答的。谢谢你。