我试图在另一页上发布一些数据,我有一个后退按钮点击后退按钮我想重新加载带有发布数据的原始页面。
答案 0 :(得分:1)
使用$ _SESSION:
page1.php中
<?php
session_start();
$name = isset($_SESSION['name']) ? $_SESSION['name'] : '';
?>
<html>
<form method="post" action="Page2.php">
<input type="text" name="name" value="<?php echo $name; ?>" />
<input type="submit" value="Submit" />
</form>
</html>
使page2.php
<?php
session_start();
if (isset($_POST['name']))
{
$_SESSION['name'] = $_POST['name'];
}
$name = $_SESSION['name'];
?>
<html>
<form>
<span><?php echo $name; ?>" </span>
<a href="page1.php">Back</a>
</form>
</html>
答案 1 :(得分:1)
你可以使用$ _SESSION
<?php
if (!isset($_SESSION)) session_start();
if ($_POST['btnsubmit']){
$_SESSION['data1'] = $_POST['data1'];
$_SESSION['data2'] = $_POST['data2'];
$_SESSION['data3'] = $_POST['data3'];
//... and so on
}
?>
<form>
<input type="text" id="data1" value="<? echo $_SESSION['data1'];?>"/>
<input type="text" id="data2" value="<? echo $_SESSION['data2'];?>"/>
<input type="text" id="data3" value="<? echo $_SESSION['data3'];?>"/>
<input type="submit" id="btnsubmit" value="Submit"/>
</form>
<!-- and so on -->
希望这会给你一个想法