Setting Up A Form Powered By CGI
Note: For this tutorial, you must have a server that allows Perl CGI (Common Gateway Interface) scripts.
You will need to have a Perl module called CGI.pm installed for this form to work. If you have telnet access, you can type "which CGI.pm" and it should tell you where it is or if you have it. If you don’t have telnet access, you can use another CGI script to check for it. To check and see if this is already installed using another CGI script, create a Perl script that looks like this:
# hello.pl – my first perl script!
print "Hello, world!n";
The first line should be set to the location of Perl on your server. You have to chmod this script 755. If the page says "Hello, world!" then you already have it installed, but if you get an error, then you don’t. To learn how to install it, go to This Site. Once you install it, you can continue.
Now, you will need to download the CGI script and the thanks file. Click here to download the file. Open up the file "mailaform.cgi" in your text editor.
Ok, the very first line of the script should be set to the location of Perl. Leave the "-w" at the end of it. The sendmail variable should be the path to sendmail on your server. $recipient should be your email address or whomever is going to be receiving the email. Now for $sender and $subject. The sender should be the name you want all of the forms to be from and subject should be the subject of the email.
The last variable you need to edit is $thanks, which is the location to the file "thanks.txt." this would be the file thanking them for using your form. It should contain HTML, but still be saved as a text(.txt) file. You should upload this file and chmod it 777.
Now, all you have to do to finish editing the script is upload "mailaform.cgi" to your cgi-bin and chmod it 755.
To use the script, make a regular form, but instead of "<FORM>", use this line to start it: <FORM ACTION="http://www.yourserver.com/cgi-bin/mailaform.cgi" METHOD="POST">