Jump to content

question about an if() issue


foreverhex

Recommended Posts

have you echo'd out $cmd and $user to see what values they hold?  and is your problem that your conditional always returns true or that $user is always set?  if $user appears to be always set and you have register_globals ON in your php.ini file, then any superglobal ($_GET/$_POST) that has a ['user'] element set will automagically be interpreted by $user.
Link to comment
Share on other sites

[quote author=xyph link=topic=102091.msg404727#msg404727 date=1154028725]
Another thing to watch out for is that even if a variable is assigned an empty value, it will still return true on isset()
[/quote]

Well it know that there isn't a $user set and the script works fine if I take out the isset($user) of the if() statement. Here is my accual code:
[code]
<?php
$cmd = $_GET['cmd'];

//check if loged in
if(isset($user)) {
$addlink = '<center><a href="2minhate.php?cmd=add">Add your own stuff</a></center>';
} else {
$addlink = '<center><a href="checkuser.php">Login to add your own stuff</a></center>';
}

//If page = 2minhate.php?cmd=add then show form

if(($cmd == 'add') && isset($user)) {
//this is where the form goes
} else {
//show page as normall
}
?>[code]


[/code][/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.