v2.0 Beta (Originally released 06/29/03)
Last updated 11/20/03
Copyright © 2003 Jack Born
|
Quick Note: You might find some minor glitches in these docs as I wrote them after an entire day of recoding the script. Version 2.0 Beta has been rewritten from scratch using OOP (object oriented programming).
Hopefully, the code will work better across all platforms.
You'll be happy to know that there is ONLY ONE LINE that needs to be changed. To help you out, I've marked the important stuff in bold.
1- Open mailit.php in a text editor or HTML editor
2- Find $obj->recipient = array("you@your-isp.net");
and change it to your actual email address. If you want more than one person
to receive an email, then do it like so
$obj->recipient = array("you@your-isp.net", "another@yoursite.com");
3- $obj->website is optional
4- $obj->referer_check = '1'; adds additional security but is optional. If it is causing you problems... turn it off (set to zero).
5- $subject is optional, but this will be the subject line of the email you receive
6- $obj->redirect = "/dir/somepage.htm"; is optional, but is recommended. This is the page where your visitor will be sent after filling out the contact form. Having a real redirect page helps your site look congruent and professional.
7- $obj->banlist is optional. You can omit specific emails or all types of emails. Example: *@hotmail.com eliminates all hotmail. SUGGESTION: If you ban certain emails, tell your visitors so they don't get frustrated.
8- $obj->header_file and $obj->footer_file are optional. By splitting up the top half of your html 'template' into a header and footer, you can have the error page look exactly the same as every other page on your website. If you don't understand PHP very well, or if this concept is new to you, then just leave it out.
9- $css_file is optional since it's not a part of this release but may be included in future versions.
10- NOTE: file uploads are not available in the Beta version of 2.0
but still exists in the old version of 1.7
$banned_ext is highly recommended for file uploads. You want to be very selective
about what types of files you accept by email. For example, it's a very good
practice to forbid executabel (.exe) files. Please understand that you should
NEVER open an attachment or file from an unknown source. You should also have
a firewall and antivirus protection on your computer. So if you get a nasty
bug, virus, or piece of code in an email as a result of using this php code...
you've been warned and I don't want to hear about it. Tough luck bucko.
11- NOTE: file uploads are not available in the Beta version of 2.0
but still exists in the old version of 1.7
$max_file_size is self explanatory but I'll explain anyhow. You can and should
put a cap on the size of the file you are willing to receive. This number determines
the Kb size of the file. Leave as is if unsure.
12- $env_report should be left alone since the bugs are still being worked out on this one
13- $obj->autoresponder is the ability to instantly send a reply email back to your visitor after they submit your form successfully. 0 is off and 1 is on. Totally optional.
14- $auto_subject has been turned off in 2.0 Beta
15- $auto_content is the message that will be sent to your visitor if you choose to turn on the autoresponder. NOTE: There's a nifty little snippet in the code that will put your visitor's name in the content if one of the form fields is 'first_name'. ANOTHER NOTE: Be careful when editing these fields. The first one needs to have a regular equal '=' sign and subsequent ones need to have a period-equal sign '.='
16- Save the mailit.php file
17- Upload the entire folder and all the files contained therein. (You don't need to upload the readme.htm file put it wouldn't hurt nothin')
18- NOTE: file uploads are not available in the Beta version of 2.0
but still exists in the old version of 1.7
Your MUST set the permissions to 777 (writeable) in order for visitors
to upload a file and send it to you as an attachment. If you are not planning
on letting users upload files and send them as attachments, then you should
NOT set the permissions to 777.
19- Create your form and make sure it posts to the mailit.php file in the correct directory. (See instructions below)
20- Done.
***Also, if you are new to PHP, then you need to know that comments in the code are identified either by // at the start of the comment or by /* at the start and */ at the end. Everything in the code commented out will not be executed by the server.
You can get help, make suggestions, and report bugs at the Ultimate Form Mail Forum.
I've included a file that is a great example of how you can set up forms to save yourself time and energy. By looking at my php code in a text editor, you'll see some nifty little tricks.
Of course, if you just want to get rocking and rolling, there is only one requirement:
The form must point to the mailit.php file!
You do this by setting the action = mailit.php or action = folder/mailit.php or wherever your mailit.php file is located.
If this doesn't make sense to you, then just open the contact.php file in a text editor and do your best to make the minor modifications you need. Grab a tutorial on html forms, and in about ten minutes you'll understand what to do.
Try opening up the contact.php file in a text editor or html editor of your choice. There are some tricks, suggestions, and shortcuts I'd like to show you.
1- There is a hidden tag or field called 'required'. This is a comma separated list of all the things that I want the visitor to fill out in order to successfully send the form. The values separated by commas must be the names of other fields in your form... but you already knew that. It is highly recommended that you require an email address... especially if the autoresponder is turned on.
2- All fields that are named more than one word are separated by an underscore rather than a space. You'll see that 'fax_no' is not 'fax no'. This was done on purpose and you should name your two word (or more) fields like this as well.
3- The script is set up to validate certain fields but only if you name them correctly in your form. The correct spellings of the fields you can use for validation are:
4- NOTE: file uploads are not available in the Beta version of 2.0
but still exists in the old version of 1.7
The field for uploading a file MUST be named 'upfile'. Not file, not file_upload,
just 'upfile'. If you name your file field something else... it won't work.
5- The checkboxes are all named the same thing: 'interest[]' There is a very good reason for this. The script goes through the array and sends out a numbered list of all the selected items in this format:
The magic is not in the 'interest' part of the name but in the square brackets '[]'. So you could name your checkboxes anything[] or books[] or toys[] or whatever. Be sure to change the value of the checkboxes in your form so the data will actually make sense when it gets emailed to you. In other words, match the 'value' hidden in your form to the text that the visitor sees. Look at the code for the contact.php form if you don't quite see what I'm referring to.
6- If you look at the code underneath the selection box for 'How many siblings do you have?' you'll see a few lines of php. If this looks alien to you, it's a shortcut that tells the server to count from 1 to 9 so that I don't have to write out a bunch of lines of code. If this confuses you, don't worry about it... it's not necessary. I just thought I'd point it out to you as a way to save yourself some energy the next time you want to create a form with a selection box and a string of number in it.
If you like it, copy the code into your next form and play around with it.
7- If you keep the value of your submit button either 'submit' or 'Submit' then you won't have to see it pop up in your email.
1- Tell your visitors which fields are required.
2- Require at least the email field
3- If you use the autoresponder option in the config.php file, then have a field named 'first_name' or 'name'... but don't have both.
4- Try submitting the contact.php form 'as-is' after you've edited the config.php file and uploaded everything to your website.
Closing Thoughts
Up until version 2.0 Beta, I had modified (quite a bit) some scripts that did some of what I wanted... but not everything. In the early versions, I borrowed extensively from Jack's Formmail v4.2 (no relation to me) by lumbroso scripts and from FORM TO EMAIL WITH ATTACHMENT by Minh Nguyen Duong (Obie). Both of these scripts had strengths, weaknesses, and yes, some bugs.
Version 2.0 Beta is a complete rewrite of the code... from top to bottom. It uses object oriented programming for cleaner code and to make it more adaptable. The code has also been written with the hopes that starting from scratch will clean out some bugs and make the code work well across all (or most) server types and php installations.
Please do not remove the headers in the scripts or pass them off as your own.
PS - You may have noticed that I made an attempt to inject some personality into these instructions in the form of mild humor and dripping sarcasm. If you were offended then you misinterpreted the message and should lighten up a little. Instructions are often very boring. So can you blame me for trying to liven it up just a little?
I hope you enjoy the script.
Jack Born
http://www.surefirewebdesign.com
Experimental... not released