Hi there Apcs_uk!
As you have Perl installed on the server, I recommend that you use the
popular FormMail script which is used as the standard email script by
the majority of web hosts.
It doesn't need Javascript to validate the form fields, the
functionality is built into the script which is actually better
because Javascript validation will be useless in a browser that has
this disabled.
Installation
=============
First, you need to download the latest formmail script from MSA [
http://www.scriptarchive.com/download.cgi?s=formmail ] which contains
important security fixes.
Unzip the file to your hard disk and then rename the formmail script
to "FoRmMaIL.pl" (note the upper/lower case) - this is important for
security reasons, if you view your web server logs you will most
likely see many 404 responses for /cgi_bin/formmail.pl, using this
method they (spammers) will never know that your script is there.
Next is the tricky part, we need to go into the Perl code and modify a
few settings.
Open the script in a text editor and find the field at the top which
looks like this:
@referers = ('scriptarchive.com','209.196.21.3');
Change this to your web server's domain name and IP address, you can
find both by doing a PING from command line window (MSDOS) e.g.:
C:\>ping www.google.com
Pinging www.google.com [216.239.51.99] with 32 bytes of data:
Reply from 216.239.51.99: bytes=32 time=93ms TTL=49
...
...
You can see that www.google.com has the IP of 216.239.51.99, you need
to do this for your own domain name and then insert the details into
the "@referers" line.
This means that only people using your site can use the script.
*** If you run into any problems in the future, the IP address may
have changed for the web server.
*** You can either change the script to reflect the new IP or you can
enter 127.0.0.1 instead.
You may also need to change the other variables which are the path to
Perl [ #!/usr/bin/perl ] and the "$mailprog" variable.
You will need to ask your host what these are.
Once you've done this, save the changes.
The Form
=========
Now, we need to prepare the HTML form to send the information to the
script.
The script can accept either the POST or GET methods but the former is
recommended (the method in the form markup must also be in UPPER
CASE).
Using the requirements that you posted, I have written a basic HTML
form for you below and marked the parts that you must change with
"<!-- ### -->":
---
<p><span style="color: red;">*</span> - Required field.</p>
<form method="POST" action="http://yoursite.com/cgi_bin/FoRmMaIL.pl">
<!-- ### -->
<input type=hidden name="env_report" value="REMOTE_ADDR,
HTTP_USER_AGENT">
<input type=hidden name="recipient" value="youremail@yoursite.com">
<!-- ### -->
<input type=hidden name="subject" value="your subject"> <!-- ### -->
<input type=hidden name="redirect"
value="http://yoursite.com/success.html"> <!-- ### -->
<input type=hidden name="required"
value="email,type_group,no_group,no_nights,arrival_date">
<input type=hidden name="sort"
value="order:subject,realname,email,phone,arrival_date,no_nights,no_group,type_group">
<input type=hidden name="print_config"
value="subject,realname,email,phone,arrival_date,no_nights,no_group,type_group">
Name:<br>
<input type=text name="realname"><br>
Email:<br>
<input type=text name="email"> <span style="color: red;">*</span><br>
Phone number:<br>
<input type=text name="phone"><br>
Arrival date:<br>
<input type=text name="arrival_date"> <span style="color:
red;">*</span> (dd/mm/yy)<br>
Number of nights:<br>
<input type=text name="no_nights"> <span style="color:
red;">*</span><br>
Number of people in your group:<br>
<input type=text name="no_group"> <span style="color:
red;">*</span><br>
Type of group:<br>
<select name="type_group">
<option value ="couple" selected="selected">Couple</option>
<option value ="family">Family</option>
<option value ="hen">Hen</option>
<option value ="stag">Stag</option>
</select> <span style="color: red;">*</span><br><br><br><br><br><br>
<input type="submit" name="Send" value="Send">
<input type="reset" name="Clear" value="Clear Form">
</form>
---
Now, just copy the above into the HTML page that you want the form to
be in, making any changes (fonts, colours, layout etc).
You will need to alter the following fields at the top of the form:
<form method="POST" action="http://yoursite.com/cgi_bin/FoRmMaIL.pl">
<!-- ### -->
Change this to your domain name.
<input type=hidden name="recipient" value="youremail@yoursite.com">
<!-- ### -->
Change this to the email address to send it to (must be
@yoursite.com).
<input type=hidden name="subject" value="your subject"> <!-- ### -->
Change this to the subject of the email e.g. "Booking from
yoursite.com".
<input type=hidden name="redirect"
value="http://yoursite.com/success.html"> <!-- ### -->
Change this to a custom success page.
Once this is done, upload the files (FoRmMaIL.pl, form page and
success page) to your webserver.
The FoRmMaIL.pl script goes in the cgi_bin and just place the others
where you like (e.g. /public_html/booking/).
And that's it!
If you need any clarification or you run into any error messages,
please do not hesitate to ask.
Kind regards,
errol-ga.
Google searches used
=====================
"formmail"
://www.google.co.uk/search?q=formmail |