First off, if you read last week's article by me (the one about site ... in PHP), I have one addition to make to make your life a little easier. If you didn't read last week's article, rea
First off, if you read last week's article by me (the one about site personalization in PHP), I have one addition to make to make your life a little easier. If you didn't read last week's article, read it. It'll help you. You can find it here: http://jumpx.com utorials/1
Now, remember how we personalized a page for your visitor? This works fine, but what do we do if they didn't use that special link, and just went to the page?
What I'm saying is, if you special personalized page was at http://www.your.host/sales.php/f=Oscar/l=Grouch but your visitor only went to http://www.your.host/sales.php. Instead of the name there would just be a blank spot! Last week I forgot to cover this.
All we have to do to fix it is to tell PHP that if they didn't leave a name, to substitute one in for them. So let's say that if they left their first name blank to make their first name "Friend". This way instead of saying "Dear Oscar:" it would say "Dear Friend:".
Put the following line of code JUST ABOVE THE LINE that says something similar to: echo "$f $l" :
if ($f == "") { $f = "Friend"; }
That way, you can use your special personalized page as a normal page and no one will be the wiser.
Password protection is something you need every once in a while. Whether it's a secret site you're running or just the control panel of your favorite script.
Sometimes you don't need a fancy solution like .htaccess if you're only worrying about a single user (you). But JavaScript passwords can be worked around, and HTML-based passwords based on cookies, written in PHP are complicated and take time to write. Htaccess is nice but it's a pain if you just want to use it for one person.
Here is a simple way to use HTTP authentication (the same you see used by htaccess) with just a few lines of code. Below are the sample contents of a file you can use.
$myusername = "myusername";
$mypassword = "mypassword";
$areaname = "My Protected Area";
if ($PHP_AUTH_USER == "" || $PHP_AUTH_PW == "" || $PHP_AUTH_USER != $myusername || $PHP_AUTH_PW != $mypassword) {
header("HTTP/1.0 401 Unauthorized");
header("WWW-Authenticate: Basic realm="$areaname"");
echo "
Defend Your Thank You Folders From URL Guessers
Defend Your Thank You Folders From URL ... Robert PlankIf you sell ... ... you're going to have a thank you page (a URL where the buyer is ... after a sale). With just a c
PHP Scripts Don't Have to End in .PHP
PHP Scripts Don't Have to End in .PHPBy Robert PlankIf you tweak your site to perform better in search rankings then you practice the science of Search Engine ... (SEO). It's possible to star
Update Prospects' Calendars Without Breaking And Entering
Ever scheduled an event like a teleseminar or product launch? Hopefully they'll copy down all the details correctly, adjust the time to match their time zone, AND actually remember to attend. Luckily there's an easy way to do all this by marking your visitor's calendar with just a couple of clicks using Microsoft Outlook.