Home >Backend Development >PHP Tutorial >Code for simple interaction between PHP and html forms

Code for simple interaction between PHP and html forms

不言
不言Original
2018-08-11 16:49:165660browse

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[&#39;name&#39;]."<br>密码:".$_GET[&#39;passworld&#39;];
//.$_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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn