一個簡單演示樣例來演示用PHP訪問表單變量
阿新 • • 發佈:2017-05-17
time 變量 value 購物車 size post方法 form sso val
processorder.php:
首先編寫表單頁面orderform.html,用post方法請求服務端腳本文件:processorder.php
orderform.html:
<!DOCTYPE html> <html> <head lang="zh_CN"> <meta charset="UTF-8"> <title>訂單頁面</title> </head> <body> <h2>Jason的購物清單</h2> <form action="processorder.php" method="post"> <label>男裝:</label><input type="text" name="cloths"/> <label>鞋子:</label><input type="text" name="shoes"/> <label>眼鏡:</label><input type="text" name="glasses"/> <input type="submit" value="提交"> </form> </body> </html>
processorder.php:
<!DOCTYPE html> <html> <head lang="zh_CN"> <meta charset="UTF-8"> <title>訂單結果</title> </head> <body> <h1>Jason的購物車</h1> <h2>訂單結果</h2> <?php $cloths=$_POST[‘cloths‘]; $shoes=$_POST[‘shoes‘]; $glasses=$_POST[‘glasses‘]; echo ‘<p>訂單提交中時間:‘; //設置時區 date_default_timezone_set(‘Asia/Shanghai‘); //按指定格式輸出數據 echo date(‘Y-m-d H:i‘); echo ‘</p>‘; echo ‘<p>您的詳細購物清單是:</p>‘; echo $cloths.‘件男裝<br/>‘; echo $shoes.‘雙鞋子<br/>‘; echo $glasses.‘副眼鏡‘; ?> </body> </html>
一個簡單演示樣例來演示用PHP訪問表單變量