PHP and several POSTs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
apinto
Forum Newbie
Posts: 4
Joined: Tue Nov 25, 2008 10:56 am

PHP and several POSTs

Post by apinto »

Hi there!

I have an Apache HTTPD reverse proxy solution which integrates several intranet services under a single extranet login. I'm currently executing the automatic login in the intranet services using HTTP POSTs. For example, with SquirrelMail I have:

Code: Select all

<form action="https://service.extranet.com/webmail/src/redirect.php" method="post" name="hform">
    <input type="hidden" name="login_username" value="<?php echo $username; ?>"/>
    <input type="hidden" name="secretkey" value="<?php echo $password; ?>"/>
</form>
<script type="text/javascript" language="javascript">
    document.hform.submit();
</script>
This successfully logs in and automatically presents the user with the SquirrelMail mailbox. The problem happens with another service, a legacy one built on IIS. There are some glitches between HTTPD and IIS, which result in occasional HTTP errors 502. The solution seems to upgrade to the latest HTTPD version, which is out of question in this project for now. The user can overcome the problem by pressing the refresh button a few times...

My question is: is it possible to simulate this refresh on server-side with PHP? That is, I would make the POST in PHP until I don't get a 502 error (with a possible delay between each try), and then present the user with the same page he would get if there wasn't any error.

Thank you very much for your attention, cheers,

AP
apinto
Forum Newbie
Posts: 4
Joined: Tue Nov 25, 2008 10:56 am

Re: PHP and several POSTs

Post by apinto »

Anyone? :o Thanks,

AP
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: PHP and several POSTs

Post by John Cartwright »

Heres an example I've used in the past

Code: Select all

 
function curl_checkpage($url) 
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    $response = curl_exec($ch); 
    
    return curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200; //200 OK!
}
You may modify it as you see fit. Enjoy.
Post Reply