in reply to Redirect page (newbie)

I'm writing a similar program and I have this code:
#!/usr/local/bin/perl -w use strict; use CGI; my $q = CGI::new(); $q->use_named_parameters(); open (PASSWD, ".PASSWORD") or die "Couldn't open file"; my $matched= 0; my $queried_user = $q->param(-name=>"user"); my $queried_pass = $q->param(-name=>"pass"); while (<PASSWD>) { my ($user,$pass) = split(/\s/,$_); if (($queried_user eq $user) and ($queried_pass eq $pass)) { $matched = 1; $q->redirect("works.html"); } } if (!$matched) { print $q->header() . $q->start_html; print "Bad Username/Password combination<br>"; print $q->end_html; }
but every time I try to run it I get an internal server error it's not
my system so I can't easily check the server logs for the specific error
Any ideas?

both .PASSWORD and works.html are in the same directory as the script

one more question, when I run this program in interactive
mode from the command line am I supposed to be seeing the
redirected website print out or what? right now I get nothing

Thanks for the help

-Etan

Replies are listed 'Best First'.
Re: Re: Redirect page (newbie)
by ozzy (Sexton) on May 04, 2001 at 21:42 UTC
    Make sure you print the redirect,

    print $q->redirect("works.html");
    Also do not forget to close the password file.

    -= Ozzy =-
      Thanks -= Ozzy =-, I'm not sure how I missed that.
      I still need help with the Internal Server Error though.


      -Etan

      P.S. code is as above but "$q->redirect("works.html");" changed to
      "print $q->redirect("works.html");"
      and added "close PASSWD;" after the end of the while loop
Re: Re: Redirect page (newbie)
by delegatrix (Scribe) on May 04, 2001 at 21:51 UTC
    Try a print in front of the redirect().