hhheng has asked for the wisdom of the Perl Monks concerning the following question:

I'm sending a post to an url, and after successfully sending the post, it will turn to another page, now how to find the another page url?
#!/usr/bin/perl use LWP 5.64; my %form; $form{"name"} = $name; $form{"email"} = $email; $form{"grade"} = $grade; my $res; my $url = "http://www.mydomain.com/register.php"; SIG{ALRM} = sub {print "timeout";}; eval{ alarm(30); $res = $ua->post($url, \%form); alarm(0); }; $page_content = $res->content if $res->is_success;
After successfully sending the post request, it will turn to something like http://www.mydomain.com/payment.php. I'm trying to find the page content of payment.php, however, the above script will still get the page content of register.php. My question now is how to detect that the request turned to payment.php and get its content then?

Replies are listed 'Best First'.
Re: How to find the url turned to
by almut (Canon) on Jun 06, 2010 at 05:42 UTC

    Are you sure the form is being posted to register.php in the first place, and not payment.php?  Note that the URL that delivers the form (what you see in the browser's location bar) is not necessarily the one the form is submitted to (rather what's specified in the action attribute of the form).

    Otherwise, there might also be a redirect being done.  To find out what exactly is going on, trace the HTTP using Firefox's Live HTTP Headers addon, or a similar tool.

      Yes, the form will be posted to register.php, and then after successfully processing the data, it will be turned to payment.php to make payments. Nothing related with the browsers, it shall be independant of the browsers.
Re: How to find the url turned to
by Khen1950fx (Canon) on Jun 06, 2010 at 09:17 UTC
    Your script is 4 years old. I'm sure that things have changed since the original post. The correct url would be http://www.mydomain.com/domains/, not register.php. Here's the original post.
      Good catch of a possibly duplicative posting, but while "choudiandian," a "SitePoint Zealot," joined sitepoint.com four years ago, the question appears to have been posted on 20100605 (at 20:51, TZ unspecified).
Re: How to find the url turned to
by ikegami (Patriarch) on Jun 06, 2010 at 06:29 UTC
    If you're talking about an HTTP redirect,
    $res->request->uri

    Completely misread.