php分多步填寫投票調查表單實現方法

來源:互聯網
上載者:User

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 "寫入完成";
?>

總結

這種做的問題在於如果使用者不小心關閉了頁面資料將要重新再填寫一次哦,不過這種方法很多大型網站都是這樣做的,包括百度的百科裡面的新手升級也是這樣處理的。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.