PHP分多步骤填写发布信息的简单方法实例代码

2015-01-24信息快讯网

有的时候,在做发布信息提交页面时,需要把很多复杂信息提交页面分成多个步骤来提交。下现就是实现的这种功能的基本方法

1.php
 
<form name=form1 id=form1 method=post action=2.php> 
基本信息1:<input type=text name=base1 /> 
基本信息2:<input type=text name=base2 /> 
<input type=submit value="下一步"> 
</form> 

2.php
 
<form name=form2 id=form2 method=post action=3.php> 
产品名称:<input type=text name=prcname /> 
产品价格:<input type=text name=price /> 
产品型号:<input type=text name=prcXH /> 
<input type=hidden name=base1 value="<?php echo $_REQUEST['base1'] ?>" /> 
<input type=hidden name=base2 value="<?php echo $_REQUEST['base2'] ?>" /> 
<input type=submit value=下一步 /> 
</form> 

3.php
 
<form name=form3 id=form3 method=post action=4.php> 
其他信息1:<input type=text name=other1 /> 
其他信息2:<input type=text name=other2 /> 
<input type=hidden name=base1 value=<?php echo $_REQUEST['base1'] ?> /> 
<input type=hidden name=base2 value=<?php echo $_REQUEST['base2'] ?> /> 
<input type=hidden name=prcname value=<?php echo $_REQUEST['prcname'] ?> /> 
<input type=hidden name=price value=<?php echo $_REQUEST['price'] ?> /> 
<input type=hidden name=prcXH value=<?php echo $_REQUEST['prcXH'] ?> /> 
<input type=submit value=确定 /> 
</form> 

4.php
 
<?php 
$base1=$_REQUEST['base1']; 
$base2=$_REQUEST['base2']; 
$prcname=$_REQUEST['prcname']; 
$price=$_REQUEST['price']; 
$prcXH=$_REQUEST['prcXH']; 
$other1=$_REQUEST['other1']; 
$other2=$_REQUEST['other2']; 

$sql1="insert into [base_table](base1,base2) values('{$base1}','{$base2}')"; 
$sql2="insert into [prc_table](prcname,price,prcXH) values('{$prcname}','{$price}','{$prcXH}')"; 
$sql3="insert into [other_table](other1,other2) values('{$other1}','{$other2}')"; 
query($sql1); 
query($sql2); 
query($sql3); 

echo "写入完成"; 
?> 
©2014-2024 dbsqp.com