当我点击保留时,$ page =保留。但当我点击另一个表格如GO时,$ page值将返回Schedule。
如果单击“保留”并且单击“GO $”页面仍然等于“保留”,我想保留$ 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>
请帮助我坚持这一天..
答案 0 :(得分:0)
试试这个:
if(isset($_POST['page'])){
(isset($_POST['page'])) ? '$page = $_POST['page']' : 'Schedule';
}
echo $page;
答案 1 :(得分: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>
使用会话