已发送表单数据php 将表单数据发送到服务器有哪两种方法?各有何特点?

php怎么获取表单中提交的数据?在获取表单数据中 , 最常用的自动全局变量是$_GET和$_POST,它们分别获取通过GET方法提交的数据和通过POST方法提交的数据 。
比如一个名称为"user"的文本框表单控件,如果用GET方法提交 , 可以用 $_GET["user"]或者$_GET['user']
获取它提交的值 。
php表单数据发送到指定邮件首先 , 我们需要去Github(网页链接)下载完整的SwiftMailer
这里主要使用到的是下载解压后lib文件夹里的内容,然后需要一些配置项,为方便管理和修改,此处我们写一个配置文件config.php,来进行配置 , 此处以QQ邮箱为例,配置项如下:
然后自定义一个函数sendMail(函数里的C是thinkphp里获取配置文件的方法,自己在不是tp里的话使用直接require就可以了)
然后在相关代码里使用调用sendMail发送邮件 , 这里以ThinkPHP里的controller为例子,使用方法如下:
发送成功后显示 ‘Done!’:
然后就可以去邮箱查看是否收取到邮件咯 。
就是这么简单 。
参考:网页链接
php怎么把表单提交的数据放到数据库中 。php数据库操作主要分为5个步骤:1连接MYSQL
2连接到你的数据库
3写SQL语句
4运行sql语句
5关闭数据库
//第一步
$con
=
mysql_connect("localhost","root","123456789");
//第二步
mysql_select_db('rankingme',$conn);
//第三步
$sql="insert
into
lili
(name,sex,et,hobby,photo,tel,address,content,time)
values
($name,$sex,$et,$hobby,$photo,$tel,$address,$content,$time)"
//第四步
mysql_query($sql);
//第五步
mysql_close($con);
php中怎么把表单提交过来的数据写入到一个文件中表单页a.php:
form action="b.php" method="get"
input name="content" type="text" /
label
input type="submit" name="Submit" value="https://www.04ip.com/post/提交"
/label
/form
写入页 b.php:
?
$str=$_GET[content];
echo $str."br";
$fp=fopen("b.txt","w");
fwrite($fp,$str);//写入
fclose($fp);
readfile("b.txt");//读取
?
PHP怎么获取表单提交的数据?。?/h2>一、用file_get_contents以get方式获取内容,需要输入内容为:
1、?php
2、$url='';
3、$html = file_get_contents($url);
4、echo $html;
5、?
二、用file_get_contents函数,以post方式获取url,需要输入内容为
1、?php
2、$url = '';
3、$data = https://www.04ip.com/post/array ('foo' = 'bar');
4、$data = https://www.04ip.com/post/http_build_query($data);
5、$opts = array (
6、'http' = array (
7、'method' = 'POST',
8、'header'= "Content-type: application/x-www-form-urlencoded\r\n" .
9、"Content-Length: " . strlen($data) . "\r\n",
10、'content' = $data
11、)
12、);
13、$ctx = stream_context_create($opts);
14、$html = @file_get_contents($url,'',$ctx);
15、?
三、用fopen打开url,以get方式获取内容,需要输入内容为
1、?php
2、$fp = fopen($url, 'r');
3、$header = stream_get_meta_data($fp);//获取信息
4、while(!feof($fp)) {
5、$result .= fgets($fp, 1024);
6、}
7、echo "url header: {$header} br":
8、echo "url body: $result";
9、fclose($fp);
10、?
四、用fopen打开url,以post方式获取内容,需要输入内容为
1、?php
2、$data = https://www.04ip.com/post/array ('foo2' = 'bar2','foo3'='bar3');
3、$data = https://www.04ip.com/post/http_build_query($data);
4、$opts = array (
5、'http' = array (
6、'method' = 'POST',
7、'header'= "Content-type: application/x-www-form-urlencoded\r\nCookie:cook1=c3;cook2=c4\r\n" .

推荐阅读