in reply to Re: Premature end of script headers
in thread Premature end of script headers
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Premature end of script headers
by Cody Pendant (Prior) on Aug 01, 2003 at 06:36 UTC | |
That's pretty much what you'd expect running just that script by itself, because there's no form feeding it with information. Here's a quick fix for your problem. Start again. Start with this code: now all the values from your form are in a hash called "%in". So if you've got a field called "Title", the contents are now easily accessed because they're in $in{'Title'}. Note that there's a case-sensitivity issue here too. If your form field is called "title" then you need $in{'title'} instead. You don't need to grab things from the hash and put them into variables, just grab them directly from the hash, i.e. do this in your mail-sending code, rather than doing that bizarre "GETVALUES" thing which is just double handling. Skip that stage altogether. Just go straight to sending the mail. And the fatalsToBrowser thing will mean you get useful error messages.
| [reply] [d/l] [select] |
by Nickd_69 (Novice) on Aug 08, 2003 at 01:54 UTC | |
| [reply] [d/l] |
by Cody Pendant (Prior) on Aug 08, 2003 at 04:14 UTC | |
You can't print to MAIL before it's opened. Do the open() thing first, then all the prints.
| [reply] [d/l] |
|
Re: Re: Re: Premature end of script headers
by Limbic~Region (Chancellor) on Aug 01, 2003 at 06:24 UTC | |
It looks like the sole purpose of the CGI is to send the form information to an email address and then redirect to a new URL. This could probably be done with just JavaScript. I came up with the following code, but have no idea if it will work correctly as I am on a machine without a web server. It is more concise and it should be a lot easier to debug than your original script. I did verify the syntax using perl -c.
You really should get in the practice of validating form information. I have turned on Taint with the -T shebang line option as a future precaution against accepting user data without sanitizing it first if the script's functionality expands. Cheers - L~R Update: With some help from the CB, a few minor nits have been corrected | [reply] [d/l] |
by Anonymous Monk on Aug 04, 2003 at 23:37 UTC | |
| [reply] [d/l] |
by Limbic~Region (Chancellor) on Aug 05, 2003 at 00:10 UTC | |
Ok - you have forgetten to use Mail::Mailer which might just be a typo on your part. I would suggest reading the docs - it can use Sendmail if you want by replacing 'smtp' with 'sendmail'. Additionally - you are printing to the MAIL filehandle, but haven't opened it anywhere. You don't want to do that. Move the my $mailer = stuff before any of the print statements and then change all the MAIL lines to $mailer. You also didn't create the CGI object used to redirect the page later. You really want to look into hash slices. It could make your life a lot easier. The problem is that unless you have done form validation using JavaScript - you might be attempting to print an uninitalized variable. See my update to your code below: That should move you along I think, still don't have a web server to test it on though. What were the errors you got with my code anyway? Cheers - L~R | [reply] [d/l] |