A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

[PHP] Neopets Login Help

1.1k views · started by Bman ·
#1
[PHP] Neopets Login Help
This is the code.

function neologin($Username, $Password)
{
// Basic check
if($Username == null || $Password == null)
{
print "ERROR: Your must enter a username or password.\n";
return false;
}

// Navigate to neopets
$html = $this->httpClient->HTTPRequest('GET', 'http://www.neopets.com/loginpage.phtml', null, array());

$postData1 = 'destination=%2Findex.phtml&username='.$Username. '&x=0&y=0';
$html = $this->httpClient->HTTPRequest('POST', 'http://www.neopets.com/hi.phtml', $postData1, array("Referer" => "http://www.neopets.com/loginpage.phtml"));

$postdata2 = 'destination=%2Findex.phtml&username='.$Username.'&password='.$Password.'&x=0&y=0';

$html = $this->httpClient->HTTPRequest('POST','http://www.neopets.com/login.phtml?',$postdata2,array('Referer' => 'http://www.neopets.com/hi.phtml'));


// Return
//return (strpos($html, 'Logout') <> 0) ? true : false;
return($pos = strrpos($html, "Logout") <> 0) ? true : false;

}


Its being used in conjunction with the UGS Framework.

But everytime I log in, with correct details, it wont return the details as valid. Always invalid.

Wondering if anyone can help me.

Nobody is on MSN so i cant ask them.

Thanks :D
#2
Just checked the first lines.

Instead of using null, do this:

<?php
function neologin($username = false, $password = false) // sets them to false if the user doesn't specify what they are
{
if (is_string($username) && is_string($password)) // ignore arrays and especially boolean
{
// etc
}
}


Also, don't use httpClient. Google a cURL tutorial or use sockets.