首页 > 解决方案 > 提交前查看联系表

问题描述

需要帮助...我希望人们在单独的页面上查看他们的表单输入,然后从第二页确认他们的提交,我该怎么做?

// 索引页面

<form action="confirm.php" method="post">
<input type="text" name="uname">
    <input type="submit" value="next">

</form>

<?php

$name = $_POST["uname"];


echo('


<form action="submit.php" action="post">

// trying to prefill the form so that on submit the values are sent to submit.php
<input  value=$name name="username"> // setting the value to be captured in the next form = php variable $name


<input type="submit" value="next">

</form>
'


)

?>

标签: javascriptphpmysqlformsinput

解决方案


您需要将预览数据保存在会话中。这只是根据您的要求的一个示例。

<form action="" method="post">
<input type="text" name="uname">
    <input type="submit" value="next">

</form>

<?php
error_reporting(0);
session_start();
$name='';
$uname='';

$name = $_POST["uname"];
echo $_SESSION['uname'] = $name; 


if($_SESSION['uname'] !=''){

?>


<form action="submit.php" action="post">
<input type="text" value="<?php echo $_SESSION['uname']; ?>" name="username">
<input type="submit" value="next">

</form>

<?php
}
?>

推荐阅读