CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
I am stumped! Please Help!



Jul 13, 2000, 10:11 PM

Post #1 of 4 (2052 views)
I am stumped! Please Help! Can't Post

I am working on this script, it is a banner rotation program designed for my website.

It uses ssi. When the program is executed, banners.cgi, a data file is read and a random line is formatted into HTML output... thus creating a random banner everytime banners.cgi is executed.

When you go to banners.cgi?action=AddBanner,
a form is displayed and you can add a new banner to the banner data file (banners.dat).

I have added a password form field to protect the data file from being written to by anyone who does not know the password.

When you click Add Banner, the form is submitted to: banners.cgi?action=WriteData.

This sub checks the password field in the form. if the correct password is given, the data will be formatted and written in to the data file.

if the password is incorrect, the program displays and error message.

The problem... No matter what the password, the invalid password message is shown.

But, if I go to... banners.cgi?action=WriteData&password=bobjingles

the part of the program that writes the data to the data file is executed.

This is what I do not understand.

If you would like to see it in action,


To see the code, goto




User / Moderator

Jul 13, 2000, 10:32 PM

Post #2 of 4 (2052 views)
Re: I am stumped! Please Help! [In reply to] Can't Post

Try replacing this line from your code...

@pairs = split(/&/,$ENV{'QUERY_STRING'});

with this slightly longer version...

if( $ENV{'REQUEST_METHOD'} eq "GET" ){
} elsif( $ENV{'REQUEST_METHOD'} eq "POST" ){
@pairs = split(/&/,$in);

You are only dealing with $ENV{'QUERY_STRING'} in your script, yet the form is sending things by method="POST". So you are missing out on many of your variables.

Also you should move action=WriteData into a hidden variable so the POST can send it also...

<input type="hidden" name="action" value="WriteData">


Jul 14, 2000, 11:35 AM

Post #3 of 4 (2052 views)
Re: I am stumped! Please Help! [In reply to] Can't Post

Well, thanks, but It does not work. Now, instead of even calling the WriteData sub, it goes back to the main part of the program... the output for the SSI.

Nothing gets written to the Data File.

Thanks anyway,



Jul 14, 2000, 12:05 PM

Post #4 of 4 (2052 views)
Re: I am stumped! Please Help! [In reply to] Can't Post

Better yet, save yourself the grief of trying to reinvent the wheel and getting it wrong and use CGI, CGI_Lite, or one of the many other CGI::* modules already out there.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives