HTML5學習之九表單與PHP互動
阿新 • • 發佈:2018-12-26
客戶端程式碼:
<!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'];
?>