Canman2005 Posted March 11, 2007 Share Posted March 11, 2007 Hi all I have a question about if statements, been trying to figure out what the solution could be, but im totally stuck. Okay, I have a simple if statement <?php if (isset($_GET['user']) != '') { print "yes"; } From the above, you will see that if the url is www.domain.com/page.php?user=dave Then it prints "yes", but if the url is www.domain.com/page.php?user= Then it prints nothing. This is fine so far, but if user doesnt exist in the url, for example www.domain.com/page.php then it prints "yes". Surley if ?user doesnt exisit in the URL, then it should print anything. Does that make sense? How can you say if user exists in the url then do the following.... Anyone? Thanks in advance Dave Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 11, 2007 Share Posted March 11, 2007 The "isset()" function returns a "true" or "false" so it will always not equal the empty string. What you want is <?php if (isset($_GET['user'])) { print "yes"; } ?> Ken Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 11, 2007 Author Share Posted March 11, 2007 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.