AJAX的表單請求POST請求方式


表單數據的提交
action : 數據提交的地址,默認是當前頁面
method : 數據提交的方式,默認是get方式
post:
把數據名稱和數據值用=連接,如果有多個的話,那么他會把多個數據組合用&進行連接,然后把數據放到url?后面傳到指定頁面
enctype : 提交的數據格式,默認application/x-www-form-urlencoded

<body>
    <form action="links/1.post.php" method="post">
    	<input type="text" name="username" placeholder="輸入名字" />
        <input type="text" name="age" placeholder="輸入年齡" />
        <input type="submit"  class="myBtn" value="提交" />
    </form>
</body>

post與get的區別只在於書寫名字和enctype的區別,post必須添加enctype類型,而get用默認的即可,同時get請求的數據量小且安全性低,數據內容暴露在url后面的鏈接里面,而post則可通過發送參數來傳遞,高效。

<?php
header('content-type:text/html;charset="utf-8"');
error_reporting(0);
//$_REQUEST
$username = $_POST['username'];
$age = $_POST['age'];

echo "你的名字:{$username},年齡:{$age}";
?>

在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM