填写2表格一次性PHP

时间:2014-02-17 09:51:09

标签: php forms

我有一个这样的表格

Arrivo:
<select name="arrivo">
<option value="2014-06-15">domenica 15 Giugno</option>
<option value="2014-06-16">lunedì 16 Giugno</option>
<option value="2014-06-17">martedì 17 Giugno</option>
Partenza:   <select name="partenza">
<option value="2014-06-15">domenica 15 Giugno</option>
<option value="2014-06-16">lunedì 16 Giugno</option>
<option value="2014-06-17">martedì 17 Giugno</option>
<option value="2014-06-18">mercoledì 18 Giugno</option>
Adulti:   
<select name="PER">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<INPUT TYPE = "Submit" VALUE = "Calcola Preventivo">
</form>

我需要一些数据(如ARRIVO E PARTENZA)将以另一种形式自动填充(将在用户点击提交后创建),这将添加一个用户必须完成的新字段。请参阅此示例(其中name和email是用户必须填写第二种形式的新字段)

Arrivo:
<input type="text" name="arrivo2" value='$_POST['arrivo']><br>
Partenza
<input type="text" name="partenza2" value='$_POST['partenza']><br>
email
<input type="text" name="email"><br>
Name
<input type="text" name="name"><br>
<INPUT TYPE = "Submit" VALUE = "emailme">

1 个答案:

答案 0 :(得分:0)

表单1

<form method="post">
<input type="text" name="name" />
<input type="hidden" name="hidname"/>
</form>

提交此表单后(我假设您知道提交表单的过程)获取会话变量中的帖子值

session_start();// this starts a session
$_SESSION['name']=$_POST['name'];
$_SESSION['hidname']=$_POST['hidname'];

来自2

<?php session_start(); ?>

<form method="post">
<input type="text" name="name2" value="<?php  if(isset($_SESSION['name'])) echo $_SESSION['name'];?>"/>
<input type="text" name="hidname2" value="<?php  if(isset($_SESSION['hidname'])) echo $_SESSION['hidname'];?>" />
</form>