Deciding on a Form to Mail Script:
There are many out there. There are many
free ones. So where do we look? You can search many script
sites, such as Hotscripts.com. You will need to search
under things like "Form Handlers".
But before you go all out searching, here's
one I use and recommend: Mail
Manage EX It's free and easy to set up, as you'll
discover. For the purposes of this tutorial, I recommend
downloading this one so you'll be able to follow along
exactly.
Download and unzip the contents to your
hard drive. You will see the following files in the folder
called mmex: formsettings.stg, mmex.php, readme.html and
sample.htm. We have no need for the sample.htm, so ignore
it. Open the readme.html and give it a read through. They
are helpful. The mmex.php file needs no updating. It just
gets uploaded to your server.
So that leaves the formsettings.stg. Why
don't we just look at it here. You'll note that there
are many configuration settings. Don't worry. We are not
using very many. The ones we're concerned with are the
ones I configured (in red). Take a look:
<?
#=================================
# Form configuration
#=================================
#
MAIN SETTINGS
$send_type = 'email';
$recipient = 'you@yourdomain.com';
$required = 'name,email1,email2,scripts,domain,cpanel,cpuser,cppass,receipt';
$confirm = '';
$formatted = '';
$preview = '';
$senderrors = '';
$SMTP_Server = 'mail.yourdomain.com';
$timezone = '';
#
DISPLAY SETTINGS
$header = '';
$footer = '';
$font_size
= '';
$font_color = '';
$font_weight = '';
$font_family = '';
$no_answer = '';
#
EMAIL SETTINGS
$cc = '';
$bcc = '';
$subject = 'Form Submission
from my site';
$emailtemplate = '';
$textemail = '';
$htmlemails = '1';
$attachments = '';
$attachdir = '';
$allowedExt = 'jpg,jpeg,gif,zip,txt,doc';
# MYSQL DATABASE SETTINGS
$db_user = '';
$db_pass = '';
$db_name = '';
$table_name = '';
$input_env_vars = '';
#
CSV FILE SETTING
$csvfile_name = '';
#
FLAT-FILE SETTING
$flatfile_name = '';
#
AFTER SUBMISSION SETTINGS
$thankyou = "Thank you
$name for your submission. <br><br>We
will email you shortly.";
$redirect = '';
$auto_respond = '';
$auto_subject = '';
$auto_content = "";
#
SECURITY SETTINGS
$flood_control = '';
$floodfile_name = '';
$interval = '';
$ip_block = '';
$ipfile_name = '';
#
PLUG-IN SETTINGS
$runplugin = '';
$pluginfile = '';
#===================================
?>
|
That's it. The rest are variables that
you don't really need. You can read the readme.html to
decide if you want to use them. Let's see what we have:
$send_type
= 'email'; - This identifies
that you want to send the results via email.
$recipient = 'you@yourdomain.com';
- This is where you want the mail to go to.
$required = 'name,email1,email2,scripts,domain,cpanel,cpuser,cppass,receipt';
- These are required fields you want the users to fill
out.
$SMTP_Server
= 'mail.yourdomain.com';
- Your server info.
$subject
= 'Form Submission from my site';
- This will appear in your email subject when someone
submits a form.
$thankyou
= "Thank you $name for your
submission. <br><br>We will email you shortly.";
- Not required, but it personalizes it a bit.
Tired of paying others to install your scripts for you?
Are you interested in telling your script installer to "Take a hike!"?
Then you need Install Your Own Scripts. The new ebook from script installer Michael Ambrosio. It's Jam-Packed with extremely easy to follow step-by-step script installation lessons.
And you learn by actually installing THREE different scripts!
Don't delay. Order Now.
Tell your installer to Take A Hike! |
Setting Required Fields In Your
Form:
You probably noticed the $required field
above. This tells the form script to check that any required
fields you specified are filled in, or it will show the
user an error message.
So now we have to go back to our form
and identify the required fields. This is a simple procedure.
We will add a new form element to identify the required
fields. It's a hidden tag - which means that the user
does not see it. It looks like this: <input
type="hidden" name="hiddenField">
Within
the hidden field tag, you need to place the NAMES of the
fields you want to make required. So if you want the fields
name,email1,email2,scripts,domain,cpanel,cpuser,cppass,receipt
to
be required, then put them in the tag like this:
<input
type="hidden" name="name,email1,email2,scripts,domain,cpanel,cpuser,cppass,receipt">
So
now your form will look like this:
<form>
<input
type="hidden"
name="name,email1,email2,scripts,domain,cpanel,cpuser,cppass,receipt">
<table width="70%" border="1"
align="center" cellpadding="5"
cellspacing="0">
<tr>
<td width="52%"> <p align="right">Name:</p></td>
<td width="48%"><input
name="name"
type="text"
id="name"
size="25"></td>
</tr>
. . . . . . . . (rest of the code remains the same)
</form>
|
The Final Step to Form Completion:
Well, we're almost there. The last remaining
piece of the puzzle is to identify the form processor
and the settings.
As you saw earlier, you have two files:
mmex.php and formsettings.stg. We need to add a couple
more tags to the form you have created.
You need to make sure that your <form>
tag has at least these two elements:
<form method="post"
action="yourdomain../../mmex.php">
Note: If your mmex.php file is uploaded
to the same folder as the form, you only need to put mmex.php
in the action field.
You need to set a hidden type in the form
to reference which settings you want for this form.
There are two ways you can do this:
If
the setting files are in the same folder as mmex.php write
only the file name:
<input type="hidden"
name="settings"
value="formsettings.stg">
If
the setting file(s) is in a different folder than mmex.php
you must write the absolute path of the settings file:
<input type="hidden"
name="settings"
value="http://www.domain.com/hr/formsettings.stg">
Now your form code will look like this:
<form
method="post"
action="http://www.domain.com/hr/mmex.php">
<input
type="hidden"
name="settings"
value="http://www.domain.com/hr/formsettings.stg">
<input
type="hidden"
name="name,email1,email2,scripts,domain,cpanel,cpuser,cppass,receipt">
<table width="70%" border="1"
align="center" cellpadding="5"
cellspacing="0">
<tr>
<td width="52%"> <p align="right">Name:</p></td>
<td width="48%"><input
name="name"
type="text"
id="name"
size="25"></td>
</tr>
. . . . . . . . (rest of the code remains the same)
</form>
|
We're
Ready To Test!
You
should now test your form. You can test the one below
from a users standpoint, but you will not receive the
emails.
Did
you see the confirmation? You can also try leaving out
a required field and see the results. Speaking of which,
don't forget to clearly mark your form which fields are
required so your users know. See the example above.
If
you built your form correctly, you will get an email whenever
your form is filled out.
That
wasn't so hard, was it? Have fun with your new skill.
End
of Part 4
I
sincerely hope you enjoyed this tutorial and that you
learned something. Once you have gained confidence in
your new found skills, try your hand at script installations.
Install
Your Own Scripts is a step-by-step guide that will
teach you just how simple it is to install your own scripts.
You'll never need to pay someone else again. |