Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Perl page redirection

by rpike (Scribe)
on Apr 30, 2010 at 13:42 UTC ( #837777=perlquestion: print w/replies, xml ) Need Help??
rpike has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I have a perl/CGI script (let's call it scriptA) that, when called, redirects to another CGI script (let's call scriptB). ScriptB essentially parses and prints an html page back to the browser for the user to fill out. When the user finishes filling out the form he/she submits it (recursive call back to scriptB). In scriptB I have a check in it whereby I check $ENV{"SCRIPT_NAME"} and also check the value returned from referer() (from CGI::Session). referer actually returns the path of scriptA when I was hoping it would return scriptB. I assume the reason why is because scriptB was initially scriptA but redirected to. Is there a way to "replace" scriptA when the initial redirection is performed? Any help would be appreciated. Thanks. Rob

Replies are listed 'Best First'.
Re: Perl page redirection
by Corion (Pope) on Apr 30, 2010 at 13:57 UTC

    You are aware that the value of $ENV{HTTP_REFERER} is sent by the client and can be any value, are you? Maybe if you show some minimal code for your scripts, and how they are supposed to interact, then we can reproduce and understand your problem better. This helps us to help you better.

Re: Perl page redirection
by rpike (Scribe) on Apr 30, 2010 at 14:23 UTC
    Posting all of the code involved would be impractical :-) but I can post the few lines that I have in that redirect and such. Script A : print redirect( -uri => ${$aFileHash}{"xscript"}); Script B gets hit : form gets printed out and the action of the form is the value that was stored in ${$aFileHash}{"xscript"} (recursive call). In Script B : After the form gets printed to screen I put in the line print $ENV{"SCRIPT_NAME"} . " | " . referer(); exit(0); at the top of the script to see what gets passed back. I have other checks dependent on what the referer is. I won't get into that because right now all I'm interested in is figuring out if scriptB was called by the form generated by scriptB. In Script A is there a way to say completely replace the script in the browser? After Script A redirects to Script B, Script A is still showing in the URI.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://837777]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2018-02-24 20:57 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (311 votes). Check out past polls.