作者herber (herber)
看板PHP
標題[請益] 按一個按鈕傳兩個變數
時間Wed Feb 27 01:01:59 2008
各位高手大家好
想請教一個問題
希望我的表單能夠在按下一個按鈕的之後
這個表單可以一次兩筆資訊給後端接收資料的 php 網頁
所以我這樣寫
不知道這樣的寫法到底對不對呢?
<form action = "parser.php" method = "post">
<input type = "image" src = "XXX.jpg">
<input type = "hidden" name = "AAA"> </input>
<input type = "hidden" name = "BBB"> </input>
</input>
</form>
<form action = "parser.php" method = "post">
<input type = "image" src = "YYY.jpg">
<input type = "hidden" name = "AAA"> </input>
<input type = "hidden" name = "CCC"> </input>
</input>
</form>
是這樣的
我剛剛試了好一陣子
我發現不論我按下的是第一個 form 裡面的按鈕
或者第二個的按鈕
在 parser.php 裡面
isset($_POST['BBB']) 似乎永遠都是 true
不知道是不是因為我這樣寫
在邏輯上有錯呢?
謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.18.177
推 chph:沒錯啊, 你把兩個隱藏欄位包在表單裡面送出, 那當然是true 02/27 01:08
→ chph:另外原po看哪本書/網站教你input可以這樣結尾的? 02/27 01:08
推 cleanwind:因為書說 html 的 tag 都是 <xxx>開始</xxx>結尾 (誤) 02/27 01:27
→ starjou:完全沒看到 指定 value 的部份呀 02/27 01:47
→ chph:部分元素不是這樣的結尾方式喔. <input ... />才是標準方式 02/27 10:44