当前位置:Gxlcms > PHP教程 > 给看下那边有错

给看下那边有错

时间:2021-07-01 10:21:17 帮助过:32人阅读

给看下那里有错,
//防止乱码
header("Content-type:text/html;charset=UTF-8");
$discuz_url = 'http://www.uuxoo.com/ ';//地址
//$login_url = $discuz_url .'/violat/query/';//地址
$url="http://www.uuxoo.com/violat/query/";

//$cookie_file = tempnam('./temp','cookie');

$ch = curl_init($url);
//echo $login_url;
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
//获取表单FORMHASH
preg_match('//i', $contents, $matches);
if(!empty($matches)) {
$formhash = $matches[1];

} else {
die('Not found the forumhash.');
}
//?vehicle_reg_no=E1Y121&vehicle_id_no=153313&have_submit=yes&submit=1&vehicle_area=赣&vehicle_type=02

$post_data = array();
//车牌号
$post_data['vehicle_reg_no'] = 'E1Y121';
//车架号
$post_data['vehicle_id_no'] = '153313';
$post_data['have_submit'] = "yes";

$post_data['submit'] = '1';
//汽车地址
$post_data['vehicle_area'] = '赣';
//帖子的hash码,这个非常关键!假如缺少这个hash码,discuz会警告你来路的页面不正确
$post_data['formhash']=$formhash;
//汽车类型
$post_data['vehicle_type'] = '02';
$aaa= $formhash;
echo $aaa;
//$urlss="http://www.uuxoo.com/violat/query/?vehicle_reg_no=E1Y121&formhash=$aaa&vehicle_id_no=153313&have_submit=yes&submit=1&vehicle_area=赣&vehicle_type=02";
//echo $urlss;
$chs = curl_init($url);

//curl_setopt($ch, CURLOPT_REFERER, $url); //伪装REFERER
curl_setopt($chs, CURLOPT_HEADER, 0);
curl_setopt($chs, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($chs, CURLOPT_POST, 1);
curl_setopt($chs, CURLOPT_POSTFIELDS, $post_data);
echo curl_exec($chs);
//echo "$ch";
curl_close($chs);
?> Curl

分享到:


------解决方案--------------------
还有就是开启错误调试
error_reporting(E_ALL);
php页面头部加入这个
个人网站http://lipichang.com 互相学习
------解决方案--------------------
代码无错,目标有问题
第一次进入的不是表单页,无法取得表单控件名

人气教程排行