表单提交及php处理表单数据的实例
|
先来看一下html form表单的源码: 表单是以 结束。action表示要将表单提交到哪个文件进行处理数据,这里是提交到feedback.php文件进行处理表单数据。 method表示以何种方式提交表单,一般有两种方式提交表单,post方式和get方式。get方式提交表单,数据会显示在url链接上,post方式提交表单,数据是隐藏的,不会显示在url链接上。 在这个实例中,有很多html input标签,这些标签都是表单元素。 php处理表单数据的代码如下: $username = $_POST['username']; $useraddr = $_POST['useraddr']; $comments = $_POST['comments']; $to = "php@h.com"; $re = "Website Feedback"; $msg = $comments; $headers = "MIME-Version: 1.0rn"; $headers .= "Content-type: text/html; charset=iso-8859-1rn"; $headers .= "From: $useraddr rn"; $headers .= "Cc: another@hotmail.com rn"; mail( $to,$re,$msg,$headers ); ?> 因为表单是以post方式提交,所以这里是使用$_POST来获取表单数据的。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
