in reply to Re: Help! Form in a File!!
in thread Help! Form in a File!!

Hey, thanks a lot for the help but i still got a bit of problems. On my form i put:
<form action="http://TheRoyalKnights.com/cgi-bin/coranto/r +qguest.cgi"> <label>Blehhhh</label><input type="text" name="submitedquo +te" size="40" /><br> <input type="hidden" value="index2.shtml" name="redirect"> +<input type="submit" value="submit" /> </form>
Then on my Perl file i have:
#!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; my $quote = $q->param("submitedquote"); open FILE, ">>rqhold.dat" or die "Can't open rqhold.dat: $!\n"; print FILE $quote, "\n"; close FILE;
When i try to access rqguest.cgi i get an internal server error, and it's chmod'ed 755, so it must be an error in the script. What could it be? Thanks for your replies, and thanks in advance. -Xzyon

Replies are listed 'Best First'.
Re: Re: Re: Help! Form in a File!!
by simon.proctor (Vicar) on Mar 10, 2002 at 00:19 UTC
    Without seeing the error output I can only think that its because you are using taint but are not then untainting the variables you read in. ie:
    # This var is not untainted my $quote = $q->param("submitedquote");
    I'd also read Ovids tutorial. for more hints on CGI stuff.

    Its also possible that you cannot open the file and your die statement has informed you of that. Take a look at your logs for more info.
Re: Re: Re: Help! Form in a File!!
by gellyfish (Monsignor) on Mar 10, 2002 at 00:43 UTC

    You aren't outputting any headers - you either need to do so or send a response indicating that you aren't going to do so.

    Update: see A CGI Program must make some output for more details

    /J\

      Hey, thanks a lot for the help, but...
      I'm a real newbie on perl.
      So, i don't know all this stuff yet.
      you talked in PHP there for me. (and i don't know PHP) ;)
      little more help plz :-D
      Thanks in Advance,
      -Xzyon

        OK, your program is not emitting any output that will be transmitted back to the browser so at the very least you will need to do something like:

        #!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; my $quote = $q->param("submitedquote"); print $q->header(); open FILE, ">>rqhold.dat" or die "Can't open rqhold.dat: $!\n"; print FILE $quote, "\n"; close FILE; print start_html(),h1('Thanks for that!),end_html();
        If you really don't want to output anything you could omit all the print statements I have added and either redirect to the original page with something like:
        print $q->redirect('/whatever.html'); # your page here
        or tell the browser you are not going to send any output by sending the 304 (not modified) status like:
        print $q->header(-status => 304);
        And then print nothing else to STDOUT. Of course this should strictly be done only in response to a GET request if one is going to follow the letter of the HTTP spec.

        /J\