Google Answers Logo
View Question
 
Q: Simple email form. ( Answered 5 out of 5 stars,   2 Comments )
Question  
Subject: Simple email form.
Category: Computers > Programming
Asked by: apcs_uk-ga
List Price: $12.50
Posted: 12 Jun 2003 11:01 PDT
Expires: 12 Jul 2003 11:01 PDT
Question ID: 216544
I have a basic website for a some holiday flats. I need to put a
contect form -on the page that will email the following.

*Arrival date (drop down dates - with validation for invalid dates
maybe?)
*Number of nights
*Number in group
*Type of group - Hen, Stag, Family, Couple
*Email address
Phone Number

Other notes

The form needs to have basic javascript to validate the fields:

Valid email address
No mandatory fields missed out. (marked above with *)

The only programming exp i have is ASP. The hosting doesnt support asp
and can only support PHP with an upgrade.

The hosting does have a CGI-BIN dir in the root and in the
/public_html dir. Hope that helps?

I am after this writing fully with instructions on how to install.

Many thanks, let me know if you need more info.

Request for Question Clarification by hammer-ga on 12 Jun 2003 11:13 PDT
Do you have Perl?

- Hammer

Request for Question Clarification by wengland-ga on 12 Jun 2003 14:15 PDT
Can you find out what scripting languages your webhost does support?

Examples are: Perl, sh, ksh, python

Once that is available, someone (or I) will quickly deliver the script to you.

Clarification of Question by apcs_uk-ga on 13 Jun 2003 04:59 PDT
Thats right, there is no PHP support.

I am told the server supports perl and python
Answer  
Subject: Re: Simple email form.
Answered By: errol-ga on 13 Jun 2003 07:42 PDT
Rated:5 out of 5 stars
 
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

Request for Answer Clarification by apcs_uk-ga on 14 Jun 2003 14:44 PDT
errol-ga ,

Thank you so much for your answer.

I followed your instruction but got the following error. I have tried
a couple of other scripts and got exactly the same message - so i
assume its a server setup thing. The only thing i didnt change is the
path to the server's mail program (i'll find out on Monday), though i
shouldnt think this is the problem)

I am sure that both the script and your instructions are spot on, and
that its a server thing thats tripping us up.

Let me know if you have any thoughts on what i can do or what i can
say to the ISP to get round the issue. Otherwise, i accept that your
answer provides the solution and will accept and rate your answer.

Thanks again (oh and they dont give you access to the server log - i
already tried:))  )

==============================================================================

Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, support@businessserve.co.uk
and inform them of the time the error occurred, and anything you might
have done that may have caused the error.

More information about this error may be available in the server error
log.



--------------------------------------------------------------------------------

Apache/1.3.27 Server at www.blackpool-self-catering.co.uk Port 80

Clarification of Answer by errol-ga on 15 Jun 2003 03:11 PDT
Hello again.

Unfortunately, that error does not really help us in diagnosing any
problems.
One thing which it may be is the CHMOD value for your .pl files.
It may be that the host will only allow Perl files with the .cgi
extension to be run.

If it isn't already, try changing the CHMOD (consult the documentation
for your FTP program) of the .pl file to 755 or:

Owner: Read, Write, Execute
Group: Read, Execute
Other: Read, Execute

I hope this helps,
errol-ga.
apcs_uk-ga rated this answer:5 out of 5 stars
Turns out to be the ISP. Your answer was clear, comprehensive and
acurate. Thanks for your time

Comments  
Subject: Re: Simple email form.
From: cubist-ga on 12 Jun 2003 17:58 PDT
 
Hello,

You can download a script at phpscriptcenter.com 
You can change the variables and there's an example form in the readme file.
Features:
• Supports unlimited forms
• You can customize the form layout
• Unlimited form feilds
• Set which form feilds are required
• Tell the script were to send a user once the form is submitted

http://www.phpscriptcenter.com/emailform.php

It's free and very easy to use.
Tell me if you will take this as an answer, I'll repost it as an answer.
greetings,
cubist-ga
Subject: Re: Simple email form.
From: hammer-ga on 13 Jun 2003 04:33 PDT
 
Cubist,

I believe apcs_uk-ga states that his ISP does not support PHP.

- Hammer

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy