Article 1: Site Personalization With PHP
|
Resource of the Day
As you grow in your knowledge of Internet Marketing, you'll learn how important it is to track your links. You need to know where your traffic comes from and understand how changes you apply to your website affects website traffic. DynaTracker allows you to track, analyze and test all of your Online Marketing Campaigns Automatically. You need DynaTracker |
Your HTML files can work as PHP scripts.
Take any HTML file you have and rename it to a PHP extension. (So for example, if your HTML file is named sales.html, rename it to sales.php).
Put sales.php on your web server and run it in your browser. You get the exact same result as you did with the HTML page. Now, for the good part.
Say you wanted to personalize one of your sales pages. Let's call that sales.php. Now, if you had a newsletter or wanted to give this "personalized link" to someone, your visitor's name could be added on-the-fly to your sales page.
Your link should look something like this:
http://www.your.host/sales.php?firstname=Big&lastname=Bird
Let's try it out:
http://www.jumpx.com/tutorials/1/example.php?f=Myfirstname
Click that link and your name should be near the top of the page.)
In this example, yourdomain.com represents your domain name and sales.php your HTML file turned PHP script. This would be the link you could give Big Bird when you ask him to visit your sales page.
Now, edit sales.php and find where you want Big Bird's name to appear. The first and last names are given to the script separately so you could have anything from "Hi Big Bird!" to "Dear Mr. Bird..." For simplicity let's just stick with showing both the first and last names for now.
Insert this anywhere into your "script":
<?php echo "$_GET[firstname] $_GET[lastname]"; ?>
Now try that sample link I gave you earlier on that sales page of yours. You should see the phrase "Big Bird" anywhere on your page.
Remember that you can stick this in anywhere on the page. So for example if you wanted it to say "Dear Big Bird," you would just do this (with the comma at the end):
Dear <?php echo "$_GET[firstname] $_GET[lastname]"; ?>,
If you wanted to show only the first name, use
<?php echo "$_GET[firstname]"; ?> instead. The same applies to the last name.
If you want to go ahead and shorten the URL even further, you can even use the letters "F" and "L" instead of firstname and lastname.
For example, try this in your page:
<?php echo "$_GET[f] $_GET[l]"; ?>
And then use this URL (substituting with your correct URL, of course):
http://www.your.host/sales.php?f=Oscar&l=Grouch
The result is the same. I think we want our URLs to look a little better, though.
The format I used in that above example was:
http://www.your.host/sales.php?f=Big&l=Bird
Now, the problem with this is that this link looks really ugly. Another setback with this format is that anything to the right of the "?" won't be indexed by some of the smaller search engines.
Here's a way to change this:
http://www.your.host/sales.php?f=Firstname&l=Lastname
To this:
http://www.your.host/sales.php/f=Firstname/l=Lastname
It's really easy. Just change your script to this:
<?php
$myvars = explode("/",$_SERVER["REQUEST_URI"]);
for ($i=0;$i<count($myvars);$i++) {
$holder = explode("=",$myvars[$i]);
$_GET{$holder[0]} = $holder[1];
}
echo "$_GET[f] $_GET[l]";
?>
And in just a few lines of code, your personalized PHP script's URL just looked a whole lot better.
I won't bore you with the details of what that script does, but it basically chops up the URL you gave it and picks out the pieces it wants using array exploding and variable-variables.
This snippet can also be used on almost any PHP script as well. (I used this method when I coded Brian Garvin's Lightning Track ad tracker... if you ever see a URL anywhere with "go.php/etc" in it, that's my script.)
Hopefully we all learned something today. This mini-tutorial was brought to you by the letters "P-H-P."
Article by Robert Plank
Experienced PHP/JavaScript Tutor
Solves 19 Of Your Most Frustrating
Direct Response Sales Page Hang-Ups
Sales Page Tactics by Rober Plank
Php Explained: Vol I, II, III Simply a must have resource!
PHP & Computer Resources
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/scottpar/public_html/desktop-wealth/res/!clickbank-computer.txt on line 3
Warning: include(http://app.feeddigest.com/digest3/JN6I0IYYMC.html) [function.include]: failed to open stream: no suitable wrapper could be found in /home/scottpar/public_html/desktop-wealth/res/!clickbank-computer.txt on line 3
Warning: include() [function.include]: Failed opening 'http://app.feeddigest.com/digest3/JN6I0IYYMC.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/scottpar/public_html/desktop-wealth/res/!clickbank-computer.txt on line 3
|
More PHP & Computer Infomation
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/scottpar/public_html/desktop-wealth/res/!computer_rssfeeds.txt on line 3
Warning: include(http://app.feeddigest.com/digest3/HYOIR1HVY1.html) [function.include]: failed to open stream: no suitable wrapper could be found in /home/scottpar/public_html/desktop-wealth/res/!computer_rssfeeds.txt on line 3
Warning: include() [function.include]: Failed opening 'http://app.feeddigest.com/digest3/HYOIR1HVY1.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/scottpar/public_html/desktop-wealth/res/!computer_rssfeeds.txt on line 3
|
|