PHP獲取表單值:php
$_POST //獲取POST提交html
$_GET // 獲取GET提交 post
<!DOCTYPE html> <html> <head> <title>php表單</title> </head> <body> <h1>PHP表單</h1> <form action="post.php" method="post"> 姓名:<input type="text" name="username"><br> 性別:<input type="text" name="xb"> <br> 地址:<input type="text" name="Address"> <br> <input type="submit" name="提交"> </form> </body> </html>
<?php $name = $_POST['username']; //定義一個name變量用來存放獲取POST提交的值 $xinbie = $_POST['xb']; //獲取POST提交的性別值 $dizhi =$_POST['Address']; echo "你輸入的姓名是:" . $name . '</br>' ; //輸出姓名 echo "你輸入的性別是:" . $xinbie . '</br>'; echo "你輸入的地址是:" . $dizhi ; ?>