【发布时间】:2014-09-30 11:18:48
【问题描述】:
我对 php 中的重定向有疑问
我有 2 页
- 索引首页
- 第二页用于进程编辑或edit.php
我的问题是..
如果我点击编辑,他肯定在 edit.php 中,如果我点击保存在 edit.php
如果我的重定向代码header('location:index.php');
如何返回或重定向到索引但仍处于逻辑 2 或$_POST['select']=='2'
这是我的代码:
<form action='' methode='post'>
<select name='select'>
<option value='1'>example1</option>
<option value='2'>example2</option>
</select>
</form>
<?php
if($_POST['select']=='1')
{
echo"<a href='?page=edit&id=$r[id]'>Edit</a>";
}
elseif($_POST['select']=='2')
{
echo"<a href='?page=edit&id=$r[id]'>Edit</a>";
}
else
{
echo"please select";
}
?>
【问题讨论】:
-
您需要在两个
$r[id]周围加上大括号({ })。除此之外,我不知道你在问什么。 -
hy worldofir 如果我的代码不完整,我很抱歉,因为它只是举例,但我的问题是更多的重定向,如 header('location:index.php');但是如何定向到索引但仍处于状态 $_POST['select']=='2'
标签: php html mysql css if-statement