Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: Passing CGI variables to other pages - September 15, 1998 at 07:44:57

You are here: irt.org | BBS | Re: Passing CGI variables to other pages [This BBS is closed]

Posted by Jason Nugent on September 15, 1998 at 07:44:57:

In Reply to: Passing CGI variables to other pages posted by Neil on September 15, 1998 at 05:33:22:

: Hi,
: Is it possible to pass CGI variables to other pages without using forms or hidden form elements? I have a page where a name and password is entered, and this leads to another page (if valid entry). I want to then pass these variables onto another page, where the only connection is a link. Any ideas?
: Ta muchly,
: Neil

Yes, this can be done.

Oh... sorry.. you wanted to know how :)

Umm, yeah - what you need to do is first submit your form containing the name and password to a CGI script (I presume this already works). The CGI script then validates the name and password and displays the resulting page if they are valid. This resulting page contains a link to another page, and you want to submit the name and password to this "other" page, yes? Ok - when you validate the name and password and create the result page, the link to your new page should be created on the fly and should contain the name and password embedded inside the link. This is how it is done in Perl:

my $username = 'Jason'; # get this from your submission form
my $password = 'alapeanutbuttersandwiches'; # ditto

## and then create the URL be embedding the above info as a
## query string.

my $url = "http://www.somwewhere.com/newpage.html?name=" . $username . "&password=" . $password;

# you can then do a redirect to the other page by printing a
# location header:

print "Location: " . $url . "\n\n";

and the new page will be loaded with your username and password embedded inside it.

You should then be able to get at the username and password embedded inside the URL either through JavaScript on the new page (using location.search), or by re-submitting the URL to a CGI script and examining the QUERY_STRING environmental variable.

Jason
Follow-ups:

You are here: irt.org | BBS | Re: Passing CGI variables to other pages [This BBS is closed]

©2018 Martin Webb