一、提交普通的form表单
m.html ——文件名称
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="m.php" method="POST">
<input type="text" name="mytext" value=""></br>
<button type="submit" name="submit">提交
</form>
</body>
</html>
m.php ——文件名称
<?php
$text = $_POST['mytext'];
echo '你传的值是:', $text;
?>
二、Jquery提交表单的方法
j.html ——文件名称
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery 提交表单的方法</title>
<script src="./denglu/jquery-3.4.1.min.js"></script>
<script>
$(document).ready(function(){
$("#submitbt").click(function(){
$("#myForm").submit(); // 通过表单的id定位提交
});
});
</script>
</head>
<body>
<form action="j.php" method="post" id="myForm">
<input type="text" name="username">
<input type="text" name="passowrd">
<button type="button" id="submitbt">提交</button>
</form>
</body>
</html>
j.php ——文件名称
<?php
$username= $_POST['username'];
$passowrd = $_POST['passowrd'];
echo '你传的值是:', $username;
echo '你传的值是:', $passowrd;
?>