Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

How to make a <a href> link run a CGI script while passing parameters?

by muralikrishna (Initiate)
on May 12, 2004 at 10:18 UTC ( [id://352684]=perlquestion: print w/replies, xml ) Need Help??

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

Hi All, I am new to CGI programming. I have a webpage with some links and I want these links to run a CGI script in my server so that the appropriate pages are loaded. In other words I want to pass the name of the link as parameter to the CGI script I am calling with the link. Can anyone tell me how can I do it as $ENV{'QUERY_STRING'} is returning me null.
  • Comment on How to make a <a href> link run a CGI script while passing parameters?

Replies are listed 'Best First'.
Re: How to make a <a href> link run a CGI script while passing parameters?
by exussum0 (Vicar) on May 12, 2004 at 10:30 UTC
    (Deja-vu) Check out CGI and the param method/function. You can easily get the value of a variable you pass with it. The format for it is

    http://mysite.com/my.cgi?variable1=my%20value&variable2=othervalue

    If you look up the HTTP & CGI specs, you will see the significans of the ? + % and & symbols. ? saying, "this is where my url location ends, the rest is variable assignments. + are spaces encoded. %## is a urlencoded character, useful for passing spaces, pluses and ANYTHING. & is a variable assignment seperator. = of course, is how you assign a value to a variable.

    Tnx Podmaster for the HTTP/CGI correction

Re: How to make a <a href> link run a CGI script while passing parameters?
by snadra (Scribe) on May 12, 2004 at 10:37 UTC
    I think it would be better, if you would use the CGI module (perldoc CGI) to get your parameters. After you know the page you want to call do a redirect to that page. You can do that using the CGI module aswell.
    print $query->redirect('http://somewhere.else/in/movie/land');

    snadra

    Sorry, it took me a while to send this post. Most of it was said already...
      I am using param() method but it is returning me a null. It is like this. My page has 2 frames. The left side frame has links like Add Product, Edit Product Info, Delete Product etc. I want these three links to call my products.cgi. I want to know how to do it. I am calling the CGI as hREF=".../admin/products.cgi", I want to know How can I pass the value???
Re: How to make a <a href> link run a CGI script while passing parameters?
by PodMaster (Abbot) on May 12, 2004 at 10:30 UTC
    $$ perl -MCGI=self_url -e die(self_url) 1=2 3=4 6=6 6=6 6=6 6=6 http://localhost/-e?1=2;3=4;6=6;6=6;6=6;6=6 at -e line 1.
    Read `perldoc CGI' for the details :)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found