2023-03-21 15:31来源:m.sf1369.com作者:宇宇
给form标签一个id,比如:id=myForm原生javascript代码,:window.onload= function(){ document.getElementById('myForm').submit();}jQuery代码:$(function(){ $('#myForm').submit();});
比如这样安排:
数据操作的PHP文件名为:insertdata.php
内容为:
include(conn.php);
if($_POST['submit']) {
$sql = insert into test(id,user_name) values('','$_POST[user_name]');
mysql_query($sql);
}
?>
表单form的PHP文件名为:adddata.php
内容为:
include(insertdata.php);
echo '
';
?>
然后用户只要访问 adddata.php 文件即可。
你是直接把name定义成了数组 你可以先打印出来你的hobby[]这个数组 看看就明白了
你的hobby本身就是一个函数
你可以在php开始的时候用extract($_POST);一下 然后用print_r($hobby);你看看你的数组就知道了
粗略的看了一下,大括号配对有问题.
应该是在$obj = new save_reg(...前面少了一个花括号{来结束class的定义.
mysql_close($conn);
}
}//在此加上一个花括号与class
$obj = new save_reg($_POST[userid],$_POST[user_pass],$_POST[sex],$_POST[email]);
然后去掉最后面的大括号.
=======
你不能在class中new 自己的实例.
============
其他如果还有错,请再逐步检查.
Failed to create directory
CCLOG(AssetsManagerEx : can not create directory %s\n, fullPath.c_str());
unzClose(zipfile);
return false;
}
}
一、用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 = array ('foo' => 'bar');
4、$data = 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 = array ('foo2' => 'bar2','foo3'=>'bar3');
3、$data = 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 .
8、Content-Length: . strlen($data) . \r\n,
9、'content' => $data
10、)
11、);
12、$context = stream_context_create($opts);
13、$html = fopen('','rb' ,false, $context);
14、$w=fread($html,1024);
15、echo $w;
16、?>
五、用fsockopen函数打开url,以get方式获取完整的数据,包括header和body,需要输入内容为
1、?php
2、function get_url ($url,$cookie=false)
3、{
4、$url = parse_url($url);
5、$query = $url[path].?.$url[query];
6、echo Query:.$query;
7、$fp = fsockopen( $url[host], $url[port]?$url[port]:80 , $errno, $errstr, 30);
8、if (!$fp) {
9、return false;
10、} else {
11、$request = GET $query HTTP/1.1\r\n;
12、$request .= Host: $url[host]\r\n;
13、$request .= Connection: Close\r\n;
14、if($cookie) $request.=Cookie: $cookie\n;
15、$request.=\r\n;
16、fwrite($fp,$request);
17、while(!@feof($fp)) {
18、$result .= @fgets($fp, 1024);
19、}
20、fclose($fp);
21、return $result;
22、}
23、}
24、//获取url的html部分,去掉header
25、function GetUrlHTML($url,$cookie=false)
26、{
27、$rowdata = get_url($url,$cookie);
28、if($rowdata)
29、{
30、$body= stristr($rowdata,\r\n\r\n);
31、$body=substr($body,4,strlen($body));
32、return $body;
33、}
34、 return false;
35、}
36、?>
参考资料:
php-file_get_contents