先来看一下html form表单的源码:
<html>
<head>
< >Feedback Form</ >
</head>
<body>
<form action=\"feedback.php\" method=\"post\">
Name:<input type=\"text\" name=\"username\" size=\"30\">
<br><br>
Email:<input type=\"text\" name=\"useraddr\" size=\"30\">
<br><br>
<textarea name=\"comments\" cols=\"30\" rows=\"5\">
</textarea><br>
<input type=\"submit\" value=\"Send Form\">
</form>
</body>
</html>
表单是以<form>开头,以</form>结束。
action表示要将表单提交到哪个文件进行处理数据,这里是提交到feedback.php文件进行处理表单数据。
method表示以何种方式提交表单,一般有两种方式提交表单,post方式和get方式。get方式提交表单,数据会显示在url链接上,post方式提交表单,数据是隐藏的,不会显示在url链接上。
在这个实例中,有很多html input标签,这些标签都是表单元素。
php处理表单数据的代码如下:
<?php
$username = $_POST[\'username\'];
$useraddr = $_POST[\'useraddr\'];
$comments = $_POST[\'comments\'];
$to = \"php@h.com\";
$re = \"Website Feedback\";
$msg = $comments;
$headers = \"MIME-Version: 1.0\\r\\n\";
$headers .= \"Content-type: text/html; charset=iso-8859-1\\r\\n\";
$headers .= \"From: $useraddr \\r\\n\";
$headers .= \"Cc: another@hotmail.com \\r\\n\";
mail( $to, $re, $msg, $headers );
?>
因为表单是以post方式提交,所以这里是使用$_POST来获取表单数据的。
继续阅读与本文标签相同的文章
上一篇 :
MCN洗牌加速,“产业化”能力成为生死门槛
下一篇 :
你好哇,机器人
-
微软建议企业客户卸载KB4520062累积更新
2026-05-14栏目: 教程
-
他让我国芯片研究停滞13年,还骗走11亿研发资金,现状如何?
2026-05-14栏目: 教程
-
健乐教学机器人可开展的教学实训内容
2026-05-14栏目: 教程
-
5G套餐曝光遭“吐槽”,iphone11受追捧,导致苹果11销量比较高
2026-05-14栏目: 教程
-
为什么修电脑的叫自己不要杀毒和清理垃圾?
2026-05-14栏目: 教程
