用户输出表单处理php

php中的表单输入处理,我用两个文件,在linux输出: touch php_post1.html php_post1.php 

php_post1.html代码如下:

 1 <!doctype html>
 2 <html>
 3 <head>
 4 <title>POST方式数据提交</title>
 5 <meta http-equiv="content-type" content="text/html" charset="utf-8"/>
 6 </head>
 7 <body>
 8 <form method="post" action="php_post1.php">
 9 名字:<input type="text" name="fname"/>
10 <br/>
11 年龄:<input type="text" name="age"/>
12 <br/>
13 <input type="submit" value="POST提交数据"/>
14 </form>
15 </body>
16 </html>

上面代码把表单内数据提交到php_post1.php文件中。

php_post1.php代码如下:

<!doctype html>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html" charset="utf-8"/>
</head>
<body>
<?php
echo "我叫".$_POST['fname']."。今年".$_POST['age']."岁!";
?>
</body>
</html>

上面代码把$_POST['fname']和$_POST['age']中的数据利用函数echo打印到网页中。

原文地址:https://www.cnblogs.com/UncleFreak/p/5685474.html