in reply to form help

Here is the bare bones to get you started. This CGI will display a short form when first called and process the input of the generated form when called by that form. You may find my tutorial at CGI Help Guide useful in getting it working (this is now part of Ovid's excellent CGI tutorial so you should see it there)

#!/usr/local/bin/perl -wT use strict; # ensure all fatals go to browser during debugging and setup # *don't* uncomment these 5 lines on production code for security #BEGIN { # $|=1; # print "Content-type: text/html\n\n"; # use CGI::Carp('fatalsToBrowser'); #} $|=1; print "Content-type: text/html\n\n"; # print a header # make the environment safer delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; $ENV{'PATH'} = '/usr/bin:/usr/local/bin'; # CGI.pm stuff use CGI; $CGI::DISABLE_UPLOADS = 1; # disable uploads $CGI::POST_MAX = 1024; # limit post to 1kB my $query = new CGI; # get a CGI object # a few config vars my $mail_prog = '/usr/lib/sendmail'; my $our_email = 'us@us.com'; my $us = "Just another Perl Hacker"; # get our form input from our CGI.pm object my $formid= $query->param('formid') || ''; my $name = $query->param('name') || ''; my $email = $query->param('email') || ''; my $fax = $query->param('fax') || ''; # logic to decide what to do if ($formid eq "myform") { if ($name and ($email or $fax)) { &Send_Mail; &Thanks; } else { &Error("Invalid input, use Back button and try again") } } else { &Show_Form; # first time dispay form } exit; ################# SUBROUTINES ################### sub Send_Mail { open ('MAIL', "|$mail_prog -t") or die "Can't open mail $!\n"; print MAIL <<" TEXT"; To: $our_email Reply-to: $our_email From: $us Subject: Form Input Name: $name Email: $email FAX: $fax TEXT close MAIL; } sub Thanks { print <<" HTML"; <p>Thanks for using my form HTML } sub Error { my $message = shift; print <<" HTML"; <p>$message HTML } sub Show_Form { print <<" HTML"; <html> <head> <title>Form</title> </head> <body> <form method="POST" action="/cgi-bin/mycgi.cgi"> <input type="hidden" name="formid" value="myform"> <table border="0" width="400" cellspacing="0" cellpadding="0"> <tr> <td width="60">Name </td> <td width="340"><input type="text" name="name" size="20"></t +d> </tr> <tr> <td width="60">Email </td> <td width="340"><input type="text" name="email" size="20"></ +td> </tr> <tr> <td width="60">FAX </td> <td width="340"><input type="text" name="fax" size="20"></td +> </tr> <tr> <td width="60"></td> <td width="340"> <input type="submit" value="Submit" name="submit"> <input type="reset" value="Reset" name="reset"> </td> </tr> </table> </form> </body> </html> HTML }

cheers

Update

Fixed path typos in $ENV{'PATH'} line thanks to c

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print