Home > Backend Development > PHP Tutorial > ,关于curl模拟登陆

,关于curl模拟登陆

WBOY
Release: 2016-06-13 12:41:12
Original
918 people have browsed it

高手进,关于curl模拟登陆

本帖最后由 dz215136304 于 2013-04-04 10:25:43 编辑 模拟登陆织梦,版本5.7,已经去掉后台验证码,不知道为啥一直登陆不上(提示登陆成功却又跳回登陆地址)


<br />
<br />
<?php<br />
$cookie_file    =    tempnam('./temp','cookie');<br />
$login_url        =    'http://localhost/dedecms/dede/login.php';<br />
$post_fields    =    'gotopage=%2Fdedecms%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=123456&sm1=';<br />
<br />
$ch = curl_init($login_url);<br />
curl_setopt($ch, CURLOPT_HEADER, 0);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);<br />
curl_setopt($ch, CURLOPT_POST, 1);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);<br />
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);<br />
curl_exec($ch);<br />
curl_close($ch);<br />
<br />
<br />
$url='http://localhost/dedecms/dede/article_add.php?channelid=1';<br />
$ch = curl_init($url);<br />
curl_setopt($ch, CURLOPT_HEADER, 0);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);<br />
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);<br />
$contents = curl_exec($ch);<br />
<br />
<br />
curl_close($ch);<br />
?><br />
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template