-1

当我单击保留时,$page = 保留。但是,当我单击另一个表单(如 GO)时,$page 值将返回到 Schedule。

如果单击保留并单击 GO $page 仍然等于保留,我想保留 $page 的值。

<?php 

if(isset($_POST['page'])){
    $page = $_POST['page']; 
}
else $page = 'Schedule';

echo $page;
?>

<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
    <input type="submit" name="page" value="Schedule" />
    <input type="submit" name="page" value="Resereved" />
</form>
<br /><br />
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
    <input type="text" value="" />
    <input type="submit" name="submission" value="GO" />
</form>

请帮助我坚持了1天..

4

2 回答 2

0

试试这个 :

    if(isset($_POST['page'])){
 (isset($_POST['page'])) ? '$page = $_POST['page']' : 'Schedule';
 }

 echo $page;
于 2013-02-02T08:39:17.160 回答
0
<?php 
session_start();

if(isset($_POST['page'])){
    $page = $_POST['page'];
    $_SESSION['page'] =  $page;
}
if(isset($_SESSION['page']))
{
$page = $_SESSION['page'];

}
else $page = 'Schedule';

echo $page;

?>

<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
    <input type="submit" name="page" value="Schedule" />
    <input type="submit" name="page" value="Resereved" />
</form>
<br /><br />
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
    <input type="text" value="" />
    <input type="submit" name="submission" value="GO" />
</form>

使用会话

于 2013-02-02T08:43:33.580 回答