[PHP_Day 9]_高階語法_取得HTML中的參數GET_POST
表單傳送值方式基本的有兩種(跟ASP一樣)
GET (串後頭URL)
formTest.html
1 2 3 4 5 6 7 8 9 10 11 12 13 | <html> <head> <meta charset="UTF-8"> </head> <body> <form action="getPhone.php" method="get"> <div>電話</div> <input type="text" name ="phone"> <input type="submit" value="發送"> </form> </body> </html> |
getPhone.php
1 2 3 | <?php echo "電話號碼:".$_GET["phone"]; ?> |
POST (表單傳送)
formTest.html
1 2 3 4 5 6 7 8 9 10 11 12 13 | <html> <head> <meta charset="UTF-8"> </head> <body> <form action="getPhone.php" method="post"> <div>電話</div> <input type="text" name ="phone"> <input type="submit" value="發送"> </form> </body> </html> |
getPhone.php
1 2 3 | <?php echo "電話號碼:".$_POST["phone"]; ?> |
留言
張貼留言