Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
help with if else statement
Old 03-22-2005, 03:34 PM help with if else statement
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
im having a bit of trouble with an if else statement.

here what i want to do:

if $page == "members" and the variable $member has a value (only if it has a value) that is NOT "hitraj47" or "neoboy" then include "members/$member.php"

else print "blah"

er.. does that make sense?

here is what i have at the moment:


PHP Code:
if ($page == "members" && $member == $member && !($member == "hitraj47") || !($member == "neoboy")) {
include 
"members/$member.php";

} else {
print 
"blah";

HitRaj47 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-22-2005, 03:39 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
I'd make an array of the members you want to exclude, then use in_array().

PHP Code:
$not_members = array('hitraj47''neoboy');

if(
$page == "members" && !in_array($member$not_members))
{
    include 
"members/$member.php";
}

else
{
    print 
"blah";

__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-22-2005, 03:43 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
To make sure $member has a value, you could enclose Chroder's if-else statement inside this one:
PHP Code:
if(!empty($member))
{
   

__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 03-22-2005, 03:50 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
I just noticed that you are including a file based on a variable, presumably user inputted. Be careful with this, a user can enter anything. For example, what if a user enters "../../../../somescript" or the likes? Your script allows a user to try and include any script outside of the "members" directory, which can be dangerous.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-22-2005, 04:45 PM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
thanks for your help

used a switch statement instead, then users can't access directories and it works how i want.


Last edited by HitRaj47; 03-22-2005 at 04:49 PM.. Reason: fixed
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help with if else statement
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15848 seconds with 12 queries