Archive for August, 2007

Change Contact Form CAPTCHA Question

Wednesday, August 29th, 2007

I recently had the following question from a FCF user:

QUESTION

Hi, I’d like to either simplify that math question or change it to something different. How can I do this?

ANSWER

Luckily the script is build to allow you to do this very easily. To simplify the math question, follow these simple steps.

Step One:

Open config.php in your favorite text/script editor.

Step Two:

Go-to line number 97 (or there abouts), look for the following 2 lines of code:


$rnumA = rand(0,49);
$rnumB = rand(0,49);

Step Three:

To make the math question single digits, change the above 2 lines to:


$rnumA = rand(0,9);
$rnumB = rand(0,9);

Step Four:

Save config.php and upload to your webserver.

If you would prefer to remove the math question altogether and replace with some other question, follow these steps:

Step One:

Open config.php in your favorite text/script editor.

Step Two:

Go-to line number 102 (or there abouts), look for the following 2 lines of code:


$question = "$rnumA plus $rnumB?";
$answer = $rnumA+$rnumB;

Step Three:

Change the question and required answer to something like this:


$question = "What day comes after monday?";
$answer = "tuesday";

(You can change the question and answer to pretty much anything you like!)

Step Four:

Open process_form.php and goto line 118 (or there abouts), look for the following line of code:


if($ans_one === $ans_two) {

Change the above line to:


if(strtolower($ans_one) === strtolower($ans_two)) {

This change removes the case sensitive restriction!

Step Five:
Save config.php and process_form.php then upload them to your webserver.

I told you it was easy :)

Allow sender to specify subject line

Tuesday, August 28th, 2007

I recently had the following question from a FCF user:

QUESTION

Hello, I am using your contact form script and I’d like to know if it’s possible for the sender to add his own subject to the e-mail. If so, how would I go about adding that feature?

ANSWER

This could be achieved several ways, I’ll explain the simplest method here for clarity.

Step One:

Open form.php in your favorite text/script editor.

Step Two:

Go-to line number 36 or there abouts (with the line: required.add('answer_out', 'NUMERIC');)

Step Three:

Create 1 new lines above line number 36, and enter the following :

required.add('subject_line', 'NOT_EMPTY');

We are including validation for our new subject line field - this will prompt the user to include a subject line if they try to submit the form without it. At this stage we have only included JavaScript validation - later we will also include PHP validation.

Step Four:

Goto line 46 or there abouts (with the line <div class="r">)

Insert the following code ABOVE line 46:


<div class="r">
<label for="subject_line" class="req">Subject: <em>*</em></label>
<span class="f">
<input type="text" name="subject_line" size="40" id="subject_line" onBlur="trim('subject_line')">
</span>
</div>

Step Five:

Save form.php, we are done with that file now.

Step Six:

Open process_form.php in your favorite text/script editor.

Step Seven:

Go to line 89 or there abouts (with the line $reqobj->add("answer_out","NUMERIC");)

Insert the following code just below line 89:


$reqobj->add("subject_line","NOT_EMPTY");

Here we have included the PHP validation which makes sure the subject line exists.

Step Eight:

Go to line 159 or there abouts (with the line // create email headers )

Insert the following code just above line 159:


$ns = new clean;
$ns->comments($subject_line);
$email_subject = $ns->message;

The above code cleans up any HTML/Script which the user may have entered in the subject line.

Step Nine:

save process_form.php and upload both form.php and process_form.php to your webserver.

What the above script modification will do
With the above changes to your scripts, you can now allow the form users to enter their own subject line. The script will validate the subject line value, and if successful, you will receive your email message with the users subject line.

Include Users IP in Contact Form Message

Monday, August 27th, 2007

I recently had the following question from a FCF user:

QUESTION

I was wondering whether there was anyway of logging the IP address of the people who submit the forms? I occasionally get kids or jokers sending in daft (although technically relevant) things to my site and I’d like to keep a little list of people to be wary of! Thanks for any info.

ANSWER

I like nice easy questions like this one :)

Step One:

Open process_form.php in your favorite text/script editor.

Step Two:

Go-to line number 161 or there abouts (with the line: // create email headers)

Step Three:

Create 1 new lines above line number 160, and enter the following :

$mail_message .= "IP Address: ".$_SERVER['REMOTE_ADDR']."\n";

(note: if you copy/paste the above code, you may need to fix the double quote characters!)

Step Four:

Save the file and upload to your server (overwrite the original process_form.php file if it already exists)

What the above script modification will do
This slight change will allow you to see what IP Address the form user has. The IP Address will appear in your email (after all the other form field data).

Send form message to sender also

Wednesday, August 15th, 2007

I recently had the following question from a FCF user:

QUESTION

‘How can I send the information in the FCF to the person completing the form, as well as to myself?’

ANSWER

In order to have the email message (which the form generates) also sent to the form user, you need to make a simple change to ‘process_form.php. Follow the simple steps below.

Step One:

Open process_form.php in your favorite text/script editor.

Step Two:

Go-to line number 163 (with the line: // send the email)

Step Three:

Create 2 new lines under line number 163, and enter the following :

$email_message = “Thank you for contacting us, we have received the following message\n\n”.$email_message;
@mail($email_from, $email_subject, $email_message, $headers);

(note: if you copy/paste the above code, you may need to fix the double quote characters!)

Step Four:

Save the file and upload to your server (overwrite the original process_form.php file if it already exists)

What the above script modification will do

With the above modification in place, your form will now send a message to the form user as well as you. However the form users message will start with the text ‘Thank you for contacting us, we have received the following message’ (and your message will appear under this).

If you send me your modification requirements, I will hopefully base a new post on your question!

Include senders name in subject line

Wednesday, August 15th, 2007

I recently had the following question from a FCF user:

QUESTION

‘I am wanting to slightly modify the subject line with the sender’s name included. Can you please let me know how this can be done?’

ANSWER

This requires very slight modification to one of the scripts (process_form.php).

Step One:

Open process_form.php in your favorite text/script editor.

Step Two:

Go-to line number 159 (with the line: // create email headers)

Step Three:

Create a new line under line number 159, and enter the following:

$email_subject .= " ".$_POST['fullname'];

Step Four:

Save the file and upload to your server (overwrite the original process_form.php file if it already exists)

What the above script modification will do

The example given above will append the form senders ‘fullname’ to the end of the subject line. Keep in mind that you already can configure the subject line in config.php (around line 34).

If you want to make the subject line have the senders name inside the subject line (i.e. not at the end of the subject line), then change the above code in Step Three to something like:

$email_subject = $_POST['fullname']." sent you a message";

The above will make the subject like look like:

Trevor McDonald sent you a message

(if the senders name is Trever McDonald)

This post will hopefully give you an idea of how to make some simple changes to your contact us form. This is based on FCF Version 3 Beta 2!

If you want to know how to do something with FCF - drop me a message!

New spam prevention blog

Tuesday, August 14th, 2007

After more than 1 year of considering using a blog system for ‘Free Contact Form‘ it’s finally here. I have decided to use this to post details on how to configure your spam prevention forms to fit your own needs (I have a list of commonly requested customizations). I also intend to occasionally write up general spam prevention articles.

Is there something you would like FCF to do which is does not currently offer? please give your suggestions?