Forum Moderators: coopster & phranque

Message Too Old, No Replies

Parameter question

how to separate and determine parameters

         

WebWalla

8:10 pm on Dec 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a form that sends 2 parameters to a Perl script. The first parameter determines which php page the script should load and the 2nd parameter should be passed through. The call to the Perl script would be along the lines of :-
myscript.cgi?first_param&second_param

I would like to compare the 1st parameter with the word internet and if true, load a php page like this:-
page1.php?keyword=second_param

If false I want to load another page like this:-
page2.php?keyword=second_param

Since I have very little knowledge of Perl I'd like any help you can give me in scripting this bit of logic.

thanks, WebWalla.

Robber

12:40 pm on Dec 11, 2002 (gmt 0)

10+ Year Member



Assuming something like this:

www.xyz.com/cgi-bin/myscript.pl?first_param=apples&second_param=oranges

To get the parameters into variables this is probably your best bet:

use CGI:

$cgi = CGI->new;

$firstParam = $cgi->param("first_param");
$secondParam = $cgi->param("second_param");

$firstParam will now contain "apples" and $secondParam will contain "oranges". Then do your test.

WebWalla

8:21 am on Dec 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks - that works just as I wanted.