重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

php提交数据代码吗,php表单的提交方式有

求助PHP如何POST提交数据

用PHP向服务器发送HTTP的POST请求,代码如下:

清徐ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

?php

/**    

* 发送post请求    

* @param string $url 请求地址    

* @param array $post_data post键值对数据    

* @return string    

*/    

function send_post($url, $post_data) {    

$postdata = http_build_query($post_data);    

$options = array(    

'http' = array(    

'method' = 'POST',    

'header' = 'Content-type:application/x-www-form-urlencoded',    

'content' = $postdata,    

'timeout' = 15 * 60 // 超时时间(单位:s)    

)    

);    

$context = stream_context_create($options);    

$result = file_get_contents($url, false, $context);             

return $result;    

}

使用的时候直接调用上面定义的send_post方法:

$post_data = array(

'username' = 'username',

'password' = 'password'

);

send_post('网址', $post_data);

php中按钮怎么提交数据到数据库中?

利用表单提交,范例代码如下:

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""

html xmlns=""

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312" /

title无标题文档/title

/head

body

table   

form name="" action="ip地址" method="post"     (这里是新增的)

tr

td valign="top" height="110"兴趣特长:/td

tdtextarea name="content"  rows="6" class="textarea0" style="width:630px" /textarea/td

/tr

tr

td valign="top"自我评价:/td

tdtextarea name="content"  rows="6" class="textarea0" style="width:630px" /textarea/td

/tr

tr

td colspan="2" align="center"input type="submit" value="提交" //td

/tr

/form (这里是新增的)

/table

/body

/html

怎么用php文件上传功能,并可以同时进行数据提交,请问代码如何写?

?php

// $_FILES["file"]["type"] 其中["file"] html中标签的name

if ((($_FILES["file"]["type"] == "image/gif") //检查上传的文件类型为gif

|| ($_FILES["file"]["type"] == "image/jpeg")//检查上传的文件类型为jpg

|| ($_FILES["file"]["type"] == "image/pjpeg"))//检查上传的文件类型为jpeg

($_FILES["file"]["size"] 20000))//检查上传的文件大小

{

if ($_FILES["file"]["error"] 0)//判断是否为错误

{

echo "Return Code: " . $_FILES["file"]["error"] . "br /";//如果错误则输出错误信息

}

else

{

echo "Upload: " . $_FILES["file"]["name"] . "br /"; //输出文件名称

echo "Type: " . $_FILES["file"]["type"] . "br /";//输出文件类型

echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kbbr /";//输出文件大小

echo "Temp file: " . $_FILES["file"]["tmp_name"] . "br /";//输出临时文件名称

if (file_exists("upload/" . $_FILES["file"]["name"]))//判断上传文件是否存在upload文件夹里

{

echo $_FILES["file"]["name"] . " already exists. ";//如果存在则提示信息

}

else

{

move_uploaded_file($_FILES["file"]["tmp_name"],

"upload/" . $_FILES["file"]["name"]);//如果不存在则拷贝临时文件到upload文件夹

echo "Stored in: " . "upload/" . $_FILES["file"]["name"];//输出上传文件路径+文件名称

}

}

}

else

{

echo "Invalid file";//错误信息

}

?


分享题目:php提交数据代码吗,php表单的提交方式有
文章转载:http://cqcxhl.com/article/hsdcoc.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP