post和get的不同在於,post請求不會出現在url上面,會將提交的數據放到請求頭中
可以在控制檯裏查看
那麼後端如何獲取前端提交過來的數據呢
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="get.php" method="post">
<!--會將下面這些數據以get方式提交到get.php的遠程服務器中 -->
<input type="text" name="userName"><br>
<input type="password" name="userPwd"><br>
<input type="submit" value="提交"><br>
</form>
</body>
</html>
(文件名我還是用的get.php get.html)
<?php
print_r($_POST);
echo $_POST["userName"];
echo $_POST["userPwd"];