Home > Article > Backend Development > Code for simple interaction between PHP and html forms
This article brings you the code for simple interaction between html forms and PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
html form part
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表单联合PHP进行交互</title> </head> <body> <form action="http://localhost/MyService/service.php" method="get"> <!--action属性代表的是想要运行的网页的地址,methon属性代表方式--> <p>用户名:<input type="text" name="name"></p> <p>密码:<input type="password" name="passworld"></p> <input type="submit" value="确定"> </form> </body> </html>
PHP part
<?php echo "用户名:".$_GET['name']."<br>密码:".$_GET['passworld']; //.$_GET前面的.表示的是连结,文字部分用"".这里是HTML所创建的GET的创建方式,要对应 //如果用post方式提交的话,这里就随之改变,post方式直接将用户名和密码添加到地址栏中而post不用,较安全
Related recommendations:
How to implement message board style in html? (Code example)
Mini program and ThinkPHP5 combined to achieve login status (code attached)
The above is the detailed content of Code for simple interaction between PHP and html forms. For more information, please follow other related articles on the PHP Chinese website!