Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

CGI question

by Chuma (Acolyte)
on Feb 16, 2010 at 09:17 UTC ( #823440=perlquestion: print w/ replies, xml ) Need Help??
Chuma has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to get my CGI program to send certain information when you click on a link. It has to set a couple of variables, and then submit the information to the next CGI script. The only way I know of is by using Javascript, in this awfully messy way:
print ' <form name="theform" action="page2.cgi" method="post"> <input type=hidden name=x> <input type=hidden name=y> </form> <a href=javascript:document.theform.x.value=5; javascript:document.theform.y.value=7; javascript:document.theform.submit();> hello<\/a> ';
Is there a cleverer way to do this?
I also, if you pardon the heresy, tried doing it with PHP and session variables, but I couldn't figure out any way to get that working either.

Comment on CGI question
Download Code
Re: CGI question
by Corion (Pope) on Feb 16, 2010 at 09:47 UTC

    If your target accepts GET requests, you can simply issue a 302 redirect to send the user to their target location, see CGI on the redirect method.

      Oh right, I forgot to mention that. I could use a "get" instead, but that's inconvenient for other reasons. The user might input completely different values of x and y and mess things up. So I think it has to be "post".

        The user can also put in completely different values for X and Y in a POST request. If you want real security, either fetch the results on behalf of the user yourself, and output them to the user (using LWP::UserAgent), or store the data in a session and pick up the data in the target from that session.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://823440]
Approved by baxy77bax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-12-22 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls