| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Registered User
On a golden path...
Joined in May 2004
372 posts
Gave thanks: 0
Thanked 0 times
|
Code:
<?php
if ( $_SERVER['PHP_AUTH_USER'] == 'USERNAME John'){
include('specialpage.html');
} else {
include('members.html');
}
?>
Are there errors in the code? Thanks! |
|
|
|
|
|
#2 (permalink) |
|
Caffeine fiend
Comfy Contributor
Joined in Aug 2004
Lives in Reston, Virginia
Hosted on pass15
270 posts
Gave thanks: 0
Thanked 0 times
|
shouldn't it say 'John' instead of 'USERNAME John'?
__________________
Pedro Blog: http://veraperez.com Reseller: http://veraperez.net GPG/PGP Key: http://veraperez.com/public.asc |
|
|
|
|
|
#5 (permalink) |
|
Caffeine fiend
Comfy Contributor
Joined in Aug 2004
Lives in Reston, Virginia
Hosted on pass15
270 posts
Gave thanks: 0
Thanked 0 times
|
/bows
__________________
Pedro Blog: http://veraperez.com Reseller: http://veraperez.net GPG/PGP Key: http://veraperez.com/public.asc |
|
|
|
|
|
#6 (permalink) |
|
Registered User
On a golden path...
Joined in May 2004
372 posts
Gave thanks: 0
Thanked 0 times
|
One more question, how can I add more usernames to redirect to another file to the code above? I don't want to make separate files, keeping all code in index.php
![]() Last edited by qwertykb; October 5th, 2004 at 2:23 AM.. |
|
|
|
|
|
#7 (permalink) |
|
Caffeine fiend
Comfy Contributor
Joined in Aug 2004
Lives in Reston, Virginia
Hosted on pass15
270 posts
Gave thanks: 0
Thanked 0 times
|
Use SWITCH.
__________________
Pedro Blog: http://veraperez.com Reseller: http://veraperez.net GPG/PGP Key: http://veraperez.com/public.asc |
|
|
|
|
|
#8 (permalink) |
|
Surpass Fan
Super #1
Joined in Dec 2003
Lives in NJ
5,057 posts
Gave thanks: 0
Thanked 4 times
|
if you're adding a lot of names/pages- maybe those names and the corresponding pages belong in a database table.
say a table like... id / username / page 1 / john / index1.html 2 / bobby / index2.html even better is there some value you can pass to a single page through the query string and some logic in the page to act a certain way based on the username? http://mykewlsite.com/kewliopage.php?id=1&dokewl=1 just a thought as for the rule of if then versus switch is...are there more than 3 conditions? then use switch otherwise it's if then time. |
|
|
|
|
|
#9 (permalink) | |
|
surmunity freak
Comfy Contributor
Joined in Sep 2004
Lives in Baton Rouge, LA, North Amewica, USA, Earth
Hosted on D68; Serva; Pass15
143 posts
Gave thanks: 0
Thanked 0 times
|
Quote:
Your database idea is great; that's what I use on my account, but as for the query string, that wouldn't be a good deterrent aganist query string hackers. It wouldn't be very wise to store a user account based on an editable address bar. A better solution would be session variables, such as PHP Code:
__________________
Server: Pass15 twwright.net NoE Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050405 Firefox/1.0 (Ubuntu package 1.0.2) I run ubuntu hoary! |
|
|
|
|