icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » help with php code

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old October 4th, 2004, 11:09 PM   #1 (permalink)
Registered User
On a golden path...
 
Joined in May 2004
372 posts
Gave thanks: 0
Thanked 0 times
Question help with php code

Code:
<?php 

if ( $_SERVER['PHP_AUTH_USER'] == 'USERNAME John'){ 
  include('specialpage.html'); 
} else { 
  include('members.html'); 
} 
?>
I don't know why it still grabs members.html if I login with username, John
Are there errors in the code? Thanks!
qwertykb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 4th, 2004, 11:27 PM   #2 (permalink)
Caffeine fiend
Comfy Contributor
 
pvera's Avatar
 
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
pvera is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 4th, 2004, 11:41 PM   #3 (permalink)
Registered User
On a golden path...
 
Joined in May 2004
372 posts
Gave thanks: 0
Thanked 0 times
Arrow

Ahhh, that was silly of me. It works now Thanks!!
qwertykb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 4th, 2004, 11:45 PM   #4 (permalink)
sam
Surpass Fan
Super #1
 
sam's Avatar
 
Joined in Dec 2003
Lives in NJ
5,057 posts
Gave thanks: 0
Thanked 4 times
second pair of eyes never hurt anyone.

i love seeing PHP coders help each other.
sam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 5th, 2004, 12:14 AM   #5 (permalink)
Caffeine fiend
Comfy Contributor
 
pvera's Avatar
 
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
pvera is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 5th, 2004, 2:21 AM   #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..
qwertykb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 5th, 2004, 8:03 AM   #7 (permalink)
Caffeine fiend
Comfy Contributor
 
pvera's Avatar
 
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
pvera is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 5th, 2004, 10:06 AM   #8 (permalink)
sam
Surpass Fan
Super #1
 
sam's Avatar
 
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.
sam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old October 5th, 2004, 11:05 AM   #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:
Originally Posted by sam
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.

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:

$_SESSION
['userName'
As for limiting access, I have user groups, and the group the user is in limits that user to that groups permissions. I am trying to change that to a more limited approach using actions, and limiting users by the actions they are allowed. That would probably be the best approach.
__________________
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!
spartas is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On