1
Hey, I have some code that I copied from
http://www.zend.com/zend/tut/tut-using-output.phpI'm not really trying to DO anything, I just want to learn the technique. I'm trying to log in to my site using a php script which is included below. I pass it all of the variables found on my login form to the correct page for logging in but it always returns me to my index again instead of returning the XOOPS image from my admin page (which is what's located between the regular expression).
Anyway, have a look and see what you think I may be doing wrong. Do I NEED a PHPSESSID before I can submit the login? I did another version of this test submitting a SEARCH string to my site and returning the results which worked great... but logging in doesn't go.
Quote:
function login($url,$querystring,$expect){
$fp = @fopen("$url?".urlencode($querystring), "r");
if($fp){
while($in = fread($fp, 1024))
$reply .= $in;
fclose($fp);
if(ereg($expect, $reply, $reg))
return trim($reg[1]);
else
return "Error : Could not find results!
$reply
$url
$querystring
$expect
";
}
return "Error : Could not connect to site!";
}
echo login("http://www.aviary.info/user.php","&PHPSESSID=&uname=Myusername&pass=".md5("mypasswordhere")."&xoops_redirect=admin.php&op=login&Autologin=On&Privacy=0","(.*) | ");
?>