Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using ? character in web cgi program 2

Status
Not open for further replies.

marc7

Programmer
Oct 4, 2001
35
0
0
US
i was wondering if anyone could help me understand the importance of the ? when sending a user to a url--can a variable be created for the information coming after the "?" ? for example:

print a page with this link


is there a way to have find.pl recognize the value "bar123" as a variable?

i want to have an html page with a bunch of links on it and don't want to have to use a <form> tag to have it submit info to a perl script. thanks for any help.
 
Yes. It's called pass a parameter. Using CGI.pm you can retrieve it easily.

$my_param = 'get a life';

$url = 'page.cgi?action=$my_param';

print $url;


Now the recieving script (page.cgi in this case) could retrieve the parameter:

use CGI;

my $j = new CGI;

$what_to_do = $j->param(&quot;action&quot;);

print $j->header();

print &quot;I need to $what_to_do&quot;;


It's just that easy.

--Jim
 
Stuff after the ? are called the query string. The variable $ENV{'QUERY_STRING'} should contain the value of it. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top