Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a mailform

Step-by-step tutorial

Creating a mailform

by  davdesign  Posted    (Edited  )
[color green]Just to let you know that I'm relocating my server as of today, and for a period of three to four weeks, none of the links to my files on this site will work.

If you need a file from me which is linked from this site then please just email me details of the relevant link and I will send the relevant file(s) to you.

After I've relocated the server and all the files within it I shall endeavour to update all links in Tek-Tips.[/color]





Some of you may have had problems accessing these files, the links have now been corrected, apologies. ;-)[/b}

The files referred to in this can be found at

www.pinkzeppelin.com/FAQ/250-486/form.html
www.pinkzeppelin.com/FAQ/250-486/form.zip

ok here we go:

What you need to know to format this form to your own requirements:

1] Making sure its sent to YOU
2] Adding/changing form input boxes
3] Amending the PHP to suit your new form.

First of all, the best thing to say about the labels and variables not discussed from here on is to just leave them be.
You could easily render the form useless just by tweaking a variable or a label somewhere within the movie. OK.......


1...Making sure its sent to you

In frame 1 of the movie, change the variable addressee to the e-mail address you want to receive the information.
i.e. if you want the form to be sent to haggis@davdesign.co.uk then you change the action to Set Variable: "addressee" = "haggis@davdesign.co.uk"


2...Adding/changing form input boxes

At the moment there are three text input boxes. The top two for 'topic' and 'contact address' are assigned the variables 'subj' and 'mail' respectively. The third 'comment' has the variable 'mess'.
You'll notice that these variables are used in two other places:

>Frame4 'back' button
>davform.php3 file

So, you guessed it, if you want to add more boxes to your form, just assign them variables and add them to the back button and the php3 file. This is easy for the back button because you can simply copy the format already in place.
However for the PHP file its similarly simple but you must be wary of how to do it or your form might fail........


3...Amending the PHP to suit your new form.

This is what the PHP file looks like (you can open it using Notepad):
[color red]
<?php
mail($addressee, $subj, $mess,
"From:".$mail."\nReply-To:".$mail);
echo("sent=success");
?>[/color]



The first and last lines act similarly to HTML and ASP, they just let your server know that the script is PHP, so ignore them. The next line tells your server to send the form and all its components. It is this line which you have to amend.
For each additional box you add to the form, you must add the assigned variable to this line. Lets say that you add a box in your form asking for a phone number, you create a text-field in the movie and give it the variable name 'phone'. Then Line 2 of the PHP file would become:

mail($addressee, $subj, $mess, $phone,

So basically, you put a '$' before the new variable (make sure you put a comma after the last variable on this line!!.



And that's it!!! As I mentioned earlier, it would be a good idea for your sake if you left all labels and the undiscussed parts of the PHP well alone. These things are tender, and the slightest typo could ruin it completely (hence the countless entries in forums from people saying that their form doesn't work).
If this form doesn't work for you, the first thing you should do is contact your server and check if PHP can be used on their site. The chances are that your using a freebie server and it doesn't, so I suggest you hitch a ride to www.f2s.com and sign yourself up for a free site which allows PHP.

I hope this form helps everyone and I hate myself already for putting my own e-mail address in the example (should've put Old's in there LOL !!!).
If you are having problems, please don't e-mail me unless it critical, and please be patient if you do.

Cheers for now!!

dave ;-)

revision1: 21-05-01 file link changed; 'recipient' variable amended to 'addressee'
revision2: 05-10-01 links updated
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top