首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

snoopy模拟登录有关问题

2012-02-21 
snoopy模拟登录问题PHP codeHTML HEADTITLE New Document /TITLEmeta http-equivContent-Type

snoopy模拟登录问题

PHP code
<HTML> <HEAD>  <TITLE> New Document </TITLE>  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </HEAD> <BODY> <?phpinclude "Snoopy.class.php";$snoopy = new Snoopy;//获取表单需要的字段/*$snoopy->fetchform("http://www.phpx.com/happy/logging.php?action=login");echo $snoopy->results."<br />"; */$submit_url = "http://www.phpx.com/happy/logging.php?action=login"; $submit_vars["cookietime"] = "2592000";$submit_vars["loginfield"] = "username";$submit_vars["username"] = "你的用户名"; //你的用户名$submit_vars["password"] = "你的密码";  //你的密码$submit_vars["questionid"] = "0";$submit_vars["answer"] = "";    $submit_vars["loginsubmit"] = "登录";//$submit_vars["loginsubmit"] = "dl"; //可以//$submit_vars["loginsubmit"] = ""; //不行//问题1:为什么要加入上面那句:$submit_vars["loginsubmit"] = "登录",而且“登录”改为任何字眼都可以,但“”不可以$snoopy->submit($submit_url,$submit_vars);echo $snoopy->results;//问题2:登录成功后跳转到http://127.0.0.1/snoopy/index.php?> </BODY></HTML>




[解决办法]
1.这个字段是表单的一个隐藏字段,如:<input type="hidden" value="XX"/>.
2.这是由表单提交后的处理脚本决定,照你说的情况,后面判断是用的!empty($_POST[loginsubmit]),不是Snoopy的问题.
3.$snoopy->submit($submit_url,$submit_vars);
$snoopy->fetch('http://www.phpx.com/happy/index.php');//直接抓取最终页面
echo $snoopy->results;

热点排行