FaRmBoX Posted August 20, 2009 Share Posted August 20, 2009 Heres the situation. There are 2 web pages. Web page A is where I login. Web page B is where I need to go after logging in. I managed to get logged in, but I have no clue on how to get to Web page B. Please Help? Code Snippet: $url = 'http://www.website.com/webpageB.php'; $http = new HttpRequest( 'http://www.website.com/webpageA.php', HTTP_METH_POST ); $http->addPostFields( array( 'login_username' => 'username', 'login_password' => 'pass', 'remember' => '1' ) ); $http->send(); $cookies = $http->getResponseCookies(); foreach( $cookies as $cookie ) { $http->addCookies( $cookie->cookies ); } $http->setUrl($url); $http->send(); echo $http->getResponseBody(); I need to get to Web page B to parse some text and retrieve it back, but it never reaches Web page B. What in the world am I doing wrong? Please help! Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/ Share on other sites More sharing options...
jonsjava Posted August 20, 2009 Share Posted August 20, 2009 This is Javascript, isn't it? Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-902513 Share on other sites More sharing options...
FaRmBoX Posted August 21, 2009 Author Share Posted August 21, 2009 No, this is PHP... hence why it is in PHP Coding Help forum. Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-902971 Share on other sites More sharing options...
ToonMariner Posted August 21, 2009 Share Posted August 21, 2009 ermmm...... all I would say is check your login credentials and then use header('Location: http://www.website.com/webpageB.php'); Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-902974 Share on other sites More sharing options...
FaRmBoX Posted August 21, 2009 Author Share Posted August 21, 2009 ermmm...... all I would say is check your login credentials and then use header('Location: http://www.website.com/webpageB.php'); The login credentials are correct. Im not trying to load the page in my 'browser'. Im trying to login, and change the page while the php serverside code is going through in order to parse some data back and echo it to 'my' page. I hope you understand what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-903667 Share on other sites More sharing options...
oni-kun Posted August 21, 2009 Share Posted August 21, 2009 You're using some XML HTTP Request object library in PHP? I'd start and use javascript, since user login -> user page can be direct login.php -> checklogin.php checklogin.php -> user.php Your PHP method doesn't look like it could without header()... Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-903680 Share on other sites More sharing options...
ToonMariner Posted August 22, 2009 Share Posted August 22, 2009 again why not just verify the login details are correct and then redirect to page B? what's wrong with that? I am missing something or are you just over complicating things? Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-903698 Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 After your login you should check what is within the response headers, it may very well attempt to redirect you somewhere itself, you should let it (by responding to these headers accordingly). From there you may be able to get to where you want. Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-903707 Share on other sites More sharing options...
FaRmBoX Posted August 22, 2009 Author Share Posted August 22, 2009 http://us3.php.net/manual/en/class.httprequest.php Is that XML HTTP Request or am I missing something? Whats it doing in php.net? I am not trying to redirect ANYONE anywhere. I am simply trying to keep the user in MY page. When they click on a button, I want php to 'serverside' login, go to a certain page, retrieve specific text, stick it to a variable, and ECHO back on MY page. I dont even want the user to know the page exists outside of my hosting. Them being redirected there has nothing to do with. Now I hope you understand what i mean. Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-903710 Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 http://us3.php.net/manual/en/class.httprequest.php Is that XML HTTP Request or am I missing something? Whats it doing in php.net? Its nothing to do with javascripts XML HTTP Request object, I'm just not sure anyone replying has had much of an idea. Quote Link to comment https://forums.phpfreaks.com/topic/171099-help-with-httprequest/#findComment-903712 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.