PDA

View Full Version : Help Setting Up A CGI


Soad
09-02-2006, 12:53 PM
I have made a basic test contact form in Dreamweaver but the instructions just seem to be getting the bettter of me as I am very new to coding

Could anyone highlight where I add the fields ??

Here is a guide on how to setup formmail so you can use it on your hosting account.

Firstly, you need to be aware that you need 3 files for the process to work, these are:
1) Your HTML form page, this can have any number of fields and drop down boxes but it does need a few extra ones added so it works with the script.
2) The formmail.cgi/formmail.pl script that takes the data from your form, reformats it and sends it to you in an e-mail
3) An HTML page confirming to your web site visitor that the information has gone through.

Firstly, go to the site www.scriptarchive.com and download the formmail.cgi file. We recommend you read through and try to understand all the information within the help files.

Now edit the formmail file in a text editor (like notepad) and make sure that the top of the file is correct, the mail parts you need to change
are:

The top part should look like:

#!/usr/bin/perl
########################################################################
######
# FormMail Version 1.92
#
# Copyright 1995-2002 Matt Wright mattw@scriptarchive.com #
# Created 06/09/95 Last Modified 04/21/02
#
# Matt's Script Archive, Inc.: http://www.scriptarchive.com/
#
########################################################################
######


The first line of this is the most important, also make sure your version is 1.92 or later, earlier versions are insecure.

further down the file it should read:

# $mailprog defines the location of your sendmail program on your unix # # system. The flags -i and -t should be passed to sendmail in order to # # have it ignore single dots on a line and to read message for
recipients #

$mailprog = '/usr/sbin/sendmail -i -t';


then a bit further down is another important part you will definitely have to alter:

@referers = ('mydomain.name','www.mydomain.name'); MY DOMAIN HERE ??

In this line, you should include all domain names that are going to use this script, usually this is just your website with us. Make sure you put your actual hosted domain name in here.

@recipients = &fill_recipients(@referers,'services@123-reg.co.uk'); ??? what goes here (THE CHOSEN EMAIL HERE ??)

In this line ensure you put your e-mail address you are sending the files to instead of services@123-reg.co.uk. is it contact@mysite.com ??


This file can now be saved and uploaded to your website, make sure you upload the file in ASCII/text mode and NOT in binary mode. Also ensure it has read and execute permissions (755) for user group and all, as well as write permissions for the user. (DONE THAT SET TO 755)
You can set permissions for files via either your FTP client or more easily though the online file manager on your 123-reg control panel.
This is done by simply locating the formmail file, then clicking on its name (not the icon above the name) and ticking the apropriate boxes.

Now move onto your HTML file where your visitors fill in the form, make sure the code below is included.

<form action="/formmail/formmail.cgi" method="post">
Make sure this is the correct path to your formmail script. ???

<input type='hidden' name="recipient" value="services@123-reg.co.uk"/>
Make sure this is the e-mail address you are sending the details to. ?? whats this one ??

<input type='hidden' name="subject" value="Form Results"/>
Replace the value with the one you want the subject of the e-mail results to be.

<input type='hidden' name="required" value=""/>
Add any field names that the visitor has to fill in for the form to work. ???

<input type='hidden' name="redirect" value="done.html">
Put the location of the thank you HTML page here. ???

??? Do not understand most of this form (aaarrrggghhhh)
Most of it seems confusing to me any help please would be most gratefull

Thanks

4um
09-02-2006, 02:41 PM
This article doesn't answer your question directly, but might help in graspoing the concept of CGI. How CGI Works. (http://willmaster.com/support/howtoinfo/howcgiworksarticle.shtml) It's a rather simplistic article that gets the point accross.

(Sorry, I have no experience with DreamWeaver.)

FishMonger
09-02-2006, 05:23 PM
Don't use Matt's formmail script. It's not well written by todays standards, it's insecure, and unsupported. Instead you should use the formmail script from the nms project. It's a drop in replacement for Matt's script, it's well written, secure, and actively supported.
http://nms-cgi.sourceforge.net/scripts.shtml

Even Matt recommends using the nms script over his own.
http://www.scriptarchive.com/nms.html

While the free code found at my web site has not evolved much in recent years, the general programming practices and standards of CGI programs have. nms is an attempt by very active programmers in the Perl community to bring the quality of code for these types of programs up to date and eliminate some of the bad programming practices and bugs found in the existing Matt's Script Archive code.

I would highly recommend downloading the nms versions if you wish to learn CGI programming. The code you find at Matt's Script Archive is not representative of how even I would code these days. My interests and activies have moved on, however, and I just have not found the time to update all of my scripts. One of the major reasons for this is that they work for many people. For this reason, I will continue to provide them to the public, but am also pleased to make you aware of well-coded alternatives.