普通的表单登陆怎么修改成php curl模拟表单登陆 echo curl_exec($ch); 另外你的2.php是跳转了,并没有返回内容。改成echo file_get_contnets('location:http://bbs.csdn.net'); 试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 header('location:http://bbs.csdn.net');形成的 http 头HTTP/1.1 302 FoundDate: Wed, 26 Feb 2014 09:16:38 GMTlocation: http://bbs.csdn.netContent-Length: 0Content-Type: text/html;Charset=utf-8你不跟着跳转吗?curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 谢谢斑竹的帮忙 我改成了这样1.phpheader('Content-type:text/html;Charset=utf-8'); $user = 'lee'; //登陆用户名 $pass = '123456'; //登陆密码 $post_fields = "loginname={$user}&loginpass={$pass}";$ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'http://localhost/2.php');curl_setopt($ch,CURLOPT_POST,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);curl_exec($ch);curl_close($ch);2.php header('Content-Type:text/html;Charset=utf-8');if ($_POST['loginname'] == 'lee' && $_POST['loginpass'] == '123456') { header('location:http://bbs.csdn.net');} else { }执行1.php 还是空白 并没有实现跳转 #1 不是说了吗?echo curl_exec($ch);你不输出结果怎么能行?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html> <head> <script id="allmobilize" charset="utf-8" src="http://a.yunshipei.com/1327c36bdd7197e30fd9f4b48d1a5bcc/allmobilize.min.js"></script><meta http-equiv="Cache-Control" content="no-transform" /><link rel="alternate" media="handheld" href="#" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CSDN论坛首页 - CSDN.NET</title> <script src="/assets/application-2edd8c1e00c76d813e1deb8c05ba1775.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { main_page_js.index_page(); }); </script> <link href="http://csdnimg.cn/www/images/favicon.ico" rel="SHORTCUT ICON"><link rel="stylesheet" href="http://static.csdn.net/public/common/toolbar/css/index.css"> </head> <frameset cols="230,*" frameborder="no" border="0" framespacing="0"> <frame src="/left_menu" name="leftFrame" noresize="noresize" id="leftFrame" title="leftFrame" /> <frame src="/home" name="mainFrame" id="mainFrame" title="mainFrame" /> </frameset> <noframes> <body> </body> </noframes></html> php session_start()导致页面无法访问 百分求解 菜鸟疑惑……关于框架、架构及网站内容部署具体该如何理解? imagick怎么创建半透明背景png图片? mediawiki访问不了 flex 和php交互时,session的值丢失 yum remove php删除不了php 怎样才能做到限制唯一用户登录? 问下查询的问题 两台服务器架设同一网站,前端静态网页和后台源码分离 php将数据库查询结果转换为json格式 关于PHP中的缓存 Linux 下执行php脚本
形成的 http 头
HTTP/1.1 302 Found
Date: Wed, 26 Feb 2014 09:16:38 GMT
location: http://bbs.csdn.net
Content-Length: 0
Content-Type: text/html;Charset=utf-8你不跟着跳转吗?
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1.php
header('Content-type:text/html;Charset=utf-8');
$user = 'lee'; //登陆用户名
$pass = '123456'; //登陆密码
$post_fields = "loginname={$user}&loginpass={$pass}";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://localhost/2.php');
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
curl_exec($ch);
curl_close($ch);
2.php
header('Content-Type:text/html;Charset=utf-8');
if ($_POST['loginname'] == 'lee' && $_POST['loginpass'] == '123456') {
header('location:http://bbs.csdn.net');
} else {
}
执行1.php 还是空白 并没有实现跳转
echo curl_exec($ch);
你不输出结果怎么能行?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script id="allmobilize" charset="utf-8" src="http://a.yunshipei.com/1327c36bdd7197e30fd9f4b48d1a5bcc/allmobilize.min.js"></script>
<meta http-equiv="Cache-Control" content="no-transform" />
<link rel="alternate" media="handheld" href="#" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSDN论坛首页 - CSDN.NET</title>
<script src="/assets/application-2edd8c1e00c76d813e1deb8c05ba1775.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
main_page_js.index_page();
});
</script>
<link href="http://csdnimg.cn/www/images/favicon.ico" rel="SHORTCUT ICON">
<link rel="stylesheet" href="http://static.csdn.net/public/common/toolbar/css/index.css"> </head>
<frameset cols="230,*" frameborder="no" border="0" framespacing="0">
<frame src="/left_menu" name="leftFrame" noresize="noresize" id="leftFrame" title="leftFrame" />
<frame src="/home" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes>
<body>
</body>
</noframes>
</html>