Personalize Site With PHP
|
| |
Home | About Us | Computer & Internet
|
|
|
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 have 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
In this example, your.host 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 "$firstname $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 "$firstname $lastname"; ?>,
If you wanted to show only the first name, use
<?PHP echo "$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:
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("/",$REQUEST_URI); for ($i=0;$i<count($myvars);$i++) { $holder = explode("=",$myvars[$i]); ${$holder[0]} = $holder[1]; } echo "$f $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."
Assignment:
Try this script again, this time trying to insert a plus sign (+) for the value of "f", for example: example.php?f=first+name
QUIZ
1. A variable called "onion" would be referenced like this:
A: %onion B: $onion C: ***onion*** D: #onion
2. True or false: A file ending in .PHP containing only HTML (no <? or ?> tags) will behave exactly like an HTML document.
3. If you wanted to output the variables $one, $two, and $three, with a space in between each, how would you do it?
A: echo "$one two $three"; B: echo $one $two $three; C: echo $one$two$three; D: output "$one $two $three";
4. Your script is located at "http://www.your.host/sales.php". You want to pass a variable called "monkeys" with the value "20" and a variable "fork" with the value "tasty" into this script. How would you do it?
A: http://www.your.host/sales.php?monkeys?20?fork?tasty B: http://www.your.host/sales.php?monkeys=20?fork=tasty C: http://www.your.host/sales.php,monkeys=20,fork=tasty D: http://www.your.host/sales.php?monkeys=20&fork=tasty
5. Your script, located at "http://www.your.host/t.php" contains the following code:
If you go to "http://www.your.host/t.php?yellow=yes", what will you see?
A: I won't see anything. B: It will output "yes". C: The script won't even work. D: It will output "yellow".
To get the answers, place your mouse over the Queen with Question below.
|
|
|
However, please try to work out your answers first before peeking at the answers because you will learn a lot better this way.
|
| |
Here is the list of lessons you can learn from the book Simple PHP:
Chapter 1 Site Personalization With PHP Chapter 2 Password Protection With PHP Chapter 3 Autoresponders With PHP Chapter 4 More Autoresponders With PHP Chapter 5 JavaScript Fun With PHP Chapter 6 More JavaScript Fun With PHP Chapter 7 Basic Arrays and PHP Chapter 8 File Handling With PHP Chapter 9 Anything of the Day With PHP Chapter 10 Affiliate Script With PHP Chapter 11 Our Knowledge With PHP Chapter 12 Cookie Fun With PHP Chapter 13 Comparison With PHP Chapter 14 Loops With PHP Chapter 15 A Calendar With PHP Chapter 16 Functions With PHP Chapter 17 Saving With PHP
|
Each chapter uses intuitive, interactive instruction, closing with an assignment to complete before progressing to the next chapter.
As if that wasn't enough, you also get to take a quiz after each lesson and grade it yourself. You will learn why PHP is the preferred choice by programming professionals.
Ever wonder how come your name shows up peppered throughout a sales page or html email? Simple PHP teaches you how to do that.
What about protecting your content with password protection? Or an up to the minute calendar?
Learn how to create your own simple Autoresponder program.
How about this: Have you ever wished you could have one of those neat "Joke of the Day" or "Quote of the Day" features that you see on so many sites? Well, now you can and you'll be amazed at just how simple it is with Simple PHP.
Learning to use Simple PHP on your web site will save you tons of cash in the long run. The conversational tone of the lessons is shear brilliance. These lessons are written just as if you have a tutor sitting right next you, guiding you all the way through.
Having a copy of Simple PHP in your arsenal of tools is a "no-brainer." Just one of the scripts he provides will save you way more than the few dollars you are about to spend to buy your own copy of Simple PHP.
|
|
|
| |
This book retails for $17. However, I will make you a very special offer - you get the following 4 books absolutely free!
|
| |
 |
|
You hear the horror stories every day. Crashes, viruses, worms, trojans - where will it end?
Unless you take care of your computer it will end in easily rendering your pc completely useless!
A very expensive lesson to learn!
The alternative is to prepare yourself and insure that you know exactly how to protect yourself from vicious attacks.
The Last Word on eBay. In fact it is alive and kicking and making more and more people wealthy every day. Do you wish you were one of them?
Well, you can be if you're not afraid to get all the answers you will EVER need about eBay and making money.
This is NOT just another "pretty eBay face" wrapped up real nice. Everything you ever wanted to know about eBay is presented with no holds barred. Discover the reason why your first experience with eBay may have been a real embarrassing tragedy.
It truly is possible to make money using the eBay model. But, you've egot to get started the right way.
Learn how to get an online life. If you are brand new or a disappointed former newbie, you need to read this message very carefully.
If you are (or can remember when you were) someone who is consumed with a desire to have a business on the Internet, that can still become a reality for you.
It's so easy to get frustrated when you first come online with the intention of building a business. Usually, the first thing you come to realize is that if you are to succeed the first order of business is a website.
Maybe you've even joined one of those programs that promises to provide everything for you. You hop on the bandwagon and before you know it, you've spent hours and dollars building and promoting the program owners dreams.
You discover that you are spending your hard-earned cash promoting a website that is exactly like thousands of others! Learning how to build your own is the only sure fire answer to building an online business of your own.
Traffic Secrets: Please, don't be misled by the subject! This is not another redo of the same old information from some cookie cutter wannabe guru who is spouting rehashed information. Nope, this is priceless info from a regular guy just like us.
After spending way too much money on countless numbers of courses he decided enough is enough! His expensive journey allowed him to develop a no holds barred SIMPLE explanation of the ins and outs of search engine traffic.
All those expensive courses are totally worthless if you can't understand them! Well, it really CAN be explained. If you have tried to muddle your way through all that stuff you are in the right place.
Everything is written in easy to understand terms and you'll wish he had written this earlier! Don't waste another minute. You need to discover just how simple search engine optimization can be.
|
|
 |
|
|
|
 |
|
|
 |
|
|
|
Yes, you get all these 5 books for only $17.
Simple PHP + Ezy Internet Safety Guide + Starting Right with eBay + Make Your Own Web Site + Search Engine Traffic Secrets
|
| |
|
|
|
|
Immediate download
|
|
|
|
|
|
$17 only for all 5 books
|
|
|
|
|
|
 |
|
|
|
 |
|
|
|
 |
|
|
 |
|
|
 |
|
|
|
|
|
|
|
|
|
|
|
 |
|
|
100% Money Back Guarantee within 8 Weeks
|
|
| |
Your purchase through PayPal is fully secure. Your purchase is also fully guaranteed. If within the next 8 weeks you are not satisfied with your purchase, you can get full refund of your purchase. Whatever your decision, you can still keep all the 5 books. With this iron-clad guarantee, you have everything to gain and nothing to lose. Go ahead and click on the PayPal Buy button. You will be glad you did - guaranteed.
|
| |
|
|
|
|
Immediate download
|
|
|
|
|
|
$17 only for all 5 books
|
|
|
|
|
| |
Brought to you by Jacob Gan, PhD (Michigan)
|
|