文、意如
1.抓取網址列的值
<html>
<head>
<title>123</title>
</head>
<body>
<form action="" method="get">
請輸入姓名:<input type="text" name="myname"><br>
請輸入密碼:<input type="password" name="pwd"><br>
<input type="submit">
</form>
</body>
</html>
<?php
echo $_GET["myname"];
echo $_GET["pwd"];
?>

使用POST傳送資料
如果是比較隱密的資料就不建議用GET網址列來傳送。
這時就會使用POST方式傳送

抓取表單欄位
下方的notic是警告目前無此值,為正常的唷(送出表單才會抓到值)

<html>
<head>
<title>123</title>
</head>
<body>
<form action="" method="post">
請輸入姓名:<input type="text" name="myname" size="50" placeholder="請輸入姓名"><br>
員工編號:<input type="text" name="member_id" value="abc123" readonly><br>
員工編號:<input type="text" name="member_id" value="abc123" disabled><br>
請輸入密碼:<input type="password" name="pwd"><br>
Email:<input type="email" name="myemail"><br>
年月日<input type="date" name="mydate"> <br>
時間:<input type="time" name="mytime"> <br>
日期、時間:<input type="datetime-local" name="mydatetime"> <br>
數量:<input type="number" min="1" max="5" value="1" name="num"><br>
<input type="submit">
</form>
</body>
</html>
<?php
echo $_POST["myname"];
echo $_POST["pwd"];
echo $_POST["mydate"];
echo $_POST["mytime"];
echo $_POST["mydatetime"];
echo $_POST["num"];
?>
如果不想要有錯誤提醒,請自行再建立一頁php處理,當表單送出時送到另一頁表單處理
atest.php
<html>
<head>
<title>123</title>
</head>
<body>
<form action="atest3.php" method="post">
請輸入姓名:<input type="text" name="myname" size="50" placeholder="請輸入姓名"><br>
員工編號:<input type="text" name="member_id" value="abc123" readonly><br>
員工編號:<input type="text" name="member_id" value="abc123" disabled><br>
請輸入密碼:<input type="password" name="pwd"><br>
Email:<input type="email" name="myemail"><br>
年月日<input type="date" name="mydate"> <br>
時間:<input type="time" name="mytime"> <br>
日期、時間:<input type="datetime-local" name="mydatetime"> <br>
數量:<input type="number" min="1" max="5" value="1" name="num"><br>
<input type="submit">
</form>
</body>
</html>

atest3.php
<?php
echo $_POST["myname"]."您好";
echo $_POST["pwd"];
echo $_POST["mydate"];
echo $_POST["mytime"];
echo $_POST["mydatetime"];
echo $_POST["num"];
?>

Yiru@Studio - 關於我 - 意如