Myagi
07-14-2002, 03:41 AM
I would like to be able to call a subroutine based on meeting an HTTP_REFERER qualification and using input from a select box in a form to define the sub-routine that is called. What I can not figure out, being an embarrassingly uninformed newbie, is how to write the code to replace ($action) in the subroutine call after the condition is met. Can anyone please help me solve this problem?
Here is the form:
<form action="/cgi-bin/gothere.cgi" method="post">
<select name="subroutine">
<option value="null">Select an option...
<option value="null">- - - - - - - - - - - - - - - - -
<option value="Page_1">Main Page
<option value="Page_2">Another Page
<option value="Page_3">That Page
<option value="Page_4">The Other Page
</select>
<input type="submit" value="Go">
</form>
Here is the cgi
#!/usr/bin/perl
$action = $FORM{'subroutine'} ;
if ($action eq 'null')
{$action eq Page_1 ;}
if ($ENV{'HTTP_REFERER'} eq 'abc.com')
{&($action)}
elsif ($ENV{'HTTP_REFERER'} eq 'foo.com')
{&($action)}
elsif ($ENV{'HTTP_REFERER'} eq '123.com')
{&($action)}
else
{&Error_Page}
sub Error_Page
{
print "Content-type: text/html\n\n" ;
print qq~
*******html code here******
~
}
sub Page_1
{
print "Content-type: text/html\n\n" ;
print qq~
*******html code here******
~
}
sub Page_2
{
print "Content-type: text/html\n\n" ;
print qq~
*******html code here******
~
}
Here is the form:
<form action="/cgi-bin/gothere.cgi" method="post">
<select name="subroutine">
<option value="null">Select an option...
<option value="null">- - - - - - - - - - - - - - - - -
<option value="Page_1">Main Page
<option value="Page_2">Another Page
<option value="Page_3">That Page
<option value="Page_4">The Other Page
</select>
<input type="submit" value="Go">
</form>
Here is the cgi
#!/usr/bin/perl
$action = $FORM{'subroutine'} ;
if ($action eq 'null')
{$action eq Page_1 ;}
if ($ENV{'HTTP_REFERER'} eq 'abc.com')
{&($action)}
elsif ($ENV{'HTTP_REFERER'} eq 'foo.com')
{&($action)}
elsif ($ENV{'HTTP_REFERER'} eq '123.com')
{&($action)}
else
{&Error_Page}
sub Error_Page
{
print "Content-type: text/html\n\n" ;
print qq~
*******html code here******
~
}
sub Page_1
{
print "Content-type: text/html\n\n" ;
print qq~
*******html code here******
~
}
sub Page_2
{
print "Content-type: text/html\n\n" ;
print qq~
*******html code here******
~
}