当前位置: 代码迷 >> PHP >> 想 模拟登录 自己学校的教务系统,失败了,请问大神
  详细解决方案

想 模拟登录 自己学校的教务系统,失败了,请问大神

热度:34   发布时间:2016-04-28 19:12:50.0
想 模拟登录 自己学校的教务系统,失败了,请教大神
教务系统的网址:http://210.35.72.21:8888/edu/index.html (登录框在左侧)
用户名:1101002
密码:1101002s

最近在练习模拟登陆,于是我自己写了段模拟登陆教务系统,想试一下,但是一直不能登陆成功。所以想请教一下大神,问题出在哪里呢?

先谢了!


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

<body>

<?php  

$cookie_file = tempnam('./temp','cookie');
$login_url = 'http://210.35.72.21:8888/edu/student/login.do?messageflag=true';
$post_fields  = 'username=1101002&password=1101002s';

//登录并获取cookie
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
echo $text = curl_exec($ch);
curl_close($ch);

echo '<hr/>';

//利用cookie加载一个页面
$url = 'http://210.35.72.21:8888/edu/student/historySchedule.do';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
echo $text = curl_exec($ch);
curl_close($ch);

?>

</body>

------解决方案--------------------
header里面是不是还需要传递其他参数。
mark一下,回去我去测试一把
------解决方案--------------------
1、登录“选课中心”主页,输入学号和密码,点击顶端“选课退课”菜单。 
显然你没有登录
------解决方案--------------------
你确定只有用户名密码两个参数?学生,老师这个参数呢?
你要登陆一次抓包看看,可以用firebug
  相关解决方案