Articles in the ‘PHP Scripts’ Category

Hypnotic Marketing PHP Script

Posted in PHP Scripts

One of the clever tricks web designers can use to make a subtle, psychological connection with viewers is a form of “hypnotic” marketing: customizing the text or images of a webpage to correspond with the time of day.

To illustrate, we have a client who is selling an e-Book. He wanted to adjust some of the key phrases in his sales letter landing page so that readers felt as though the message was directed uniquely at them, no matter what time of day they might be viewing.

As an example, he wanted to change the line, “If you purchase right now,” to a more timely message. Now, in the morning, his webpage displays the line, “If you purchase this morning.” During the day, his message displays as, “If you purchase today.” At night, it shows, “If you purchase tonight.”

He reports that this subtle change, used strategically throughout his sales copy, has increased his conversions.

We did this with a simple PHP script, added to the functions file of his WordPress theme.

<?php
function timeofday($morning, $day, $night) {
$hour = date('G');
if (($hour > 0) && ($hour < 10)) { echo $morning; }
elseif (($hour > 9) && ($hour < 17)) { echo $day; }
else echo $night;
}
?>

This simple and elegant script checks to see what hour of the day it is. If the hour is between 1am and 10am, the morning message is displayed. If the hour is between 10am and 5pm, the daytime message is displayed. Otherwise, the nighttime message.

The usage is just as simple. Wherever he wants to customize the text in his sales letter, he just adds this function anywhere in his source file, with the appropriate text as the options:

<?php timeofday('morning text here', 'daytime text here', 'night text here'); ?>

Voila! Hypnotic marketing, with a simple PHP script.

Green Beast Contact Form gbcf-v3 in a WordPress Page Template

Posted in PHP Scripts

For those of us who use WordPress, Mike Cherim over at Green-Beast.com has volunteered a ton of time to create a fantastic, secure, and accessible contact form in PHP. The latest and most updated and secure version of this form is available as a standalone script that doesn’t work for WordPress, but is currently under development as a plugin.

However, being impatient and wanting to put this great program to use, I set out to figure out a way to make it work on this WordPress site — after quite a bit of frustration, I did manage to get it figured out, and I’m sharing it here in case there is anyone else out there who is impatient like me and wants to use Mike’s great script!

To make gbcf-v3 work, first create a page template.

Next, copy the gbcf-v3 folder from the download file over at Mike’s site to your site’s template directory (i.e. wp-content/themes/mytheme/gbcf-v3).

You’ll need to edit two lines in form.php and two lines in functions.php, which are included in the gbcf downloaded folder.

In gbcf-v3/form.php, change the $set_directory variable to the full context of your WordPress theme (i.e. wp-content/themes/mytheme/gbcf-v3, instead of the default value of gbcf-v3). Then, scroll down to the top of the form HTML code, and find the <input> tag for setting the name=”name” field. You’ll need to change this to something other than “name” because WordPress already uses this for a value by default — something like name=”gbcf-name” will work!

In gbcf-v3/files/functions.php, change the $set_directory variable to the full context of your WordPress theme (i.e. wp-content/themes/mytheme/gbcf-v3, instead of the default value of gbcf-v3). Then scroll way down to the section where the POST variables are set, and find the one called $_POST['name'] and change it to something like $_POST['gbcf-name'] (or whatever you chose in the form.php file).

Once you’ve saved these changes to those two files, you can then edit the CONFIG.php file as Mike describes in his documentation. To load the contact form on a page, just include the form in your page template, like this: <?php include(’gbcf-v3/form.php’); ?> — that’s it! Upload your new page template, create a new page using that page template and give it a whirl!

You can see the form in action here on our contact page.