Ajex——04——post請求處理

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"];

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章