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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow or Disallow execution of script

Status
Not open for further replies.

Chloeee

Programmer
Jan 16, 2001
27
0
0
US
I'm in desperate need of some help. I do ColdFusion, but not PERL.

Here's the deal...

I need my users to agree to a statement before they can execute a script. The site is in CF, but the script is CGI. I must use the CGI, and cannot rewrite the funtionality in CF.

I can send either a URL variable with a query string attached, or I can send a hidden field in a form to the CGI script either giving it permission to go ahead and run or send the user back to the main page.

I also cannot allow a user to type the URL of the CGI directly in the browser and run the script without having first gone to the statement agreement page.

Sadly, my lines of code don't seem to work at all.

Currently I'm sending a hidden field of the name "iagree" with the value of either "yes" or "no" depending on which submit they select.

Please find below the lines that I wrote for the CGI to receive and process the info. Anyone who could make it work for me would be GREATLY appreciated.

Code:
if ($fields{'iagree'} eq "no")
     { print <<Go_to_front_door&quot;;
Content-type: text/html; 
<meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://www.mydomain.com/thepage.cfm&quot;>
Go_to_front_door
exit; }
 
Wait, the code is actually this...

Code:
if ($fields{'iagree'} eq &quot;no&quot;)
     { print <<Go_to_front_door;
Content-type: text/html; 
<meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://www.suresource.net/domain_reg.cfm&quot;>
Go_to_front_door
exit; }

Thank-you :)
 
There are several syntax errors in your code. When playing with Perl, you can check your syntax with &quot;prompt> perl -c yourCode.cgi&quot;. That will tell you if you have syntax errors and will give some decent hints about where and sometimes what the error might be.

Syntax problems:
You are missing quotes in your <meta http-equiv.... tag. (Perl syntax)
The 'Content-type.. ' line MUST have a blank line after it. (CGI rule)

There must be more code than you have posted. If not, then you are not catching the information submitted from the browser at all.

Here is a block of code that does what you want,

Code:
#!/usr/local/bin/perl
use CGI; 

# create a new CGI object
my $query = new CGI;

# retrieve the 'iagree' parameter;
$iagree = $query->param('iagree');
if ($iagree eq 'yes')
{
# then, go somewhere
print $query->redirect(-uri=>'[URL unfurl="true"]http://www.suresource.net/domain_reg.cfm',-nph=>0);[/URL]
}
elsif ($iagree eq 'no') 
{
# then, go somewhere else. 
print $query->redirect(-uri=>'[URL unfurl="true"]http://www.yahoo.com',-nph=>0);[/URL]
}

HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top