客户端代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表单与PHP交互</title>
</head>
<body>
<!--action指定需要提交的服务器的地址 method为具体的提交方式-->
<form action="http://localhost:8081/MyService/Service.php" method="post">
用户名:<input type="text" name="name">
密 码:<input type="password" name="password">
<br/>
<input type="submit" value="提交">
</form>
</body>
</html>
post的提交方式比get复杂,但get可以进行资源定位。
服务器端PHP代码(Apache):
<?php
// echo 'hello world!'
echo "用户名:".$_POST['name']."<br>"."密码:".$_POST['password'];
?>