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 Link to comment https://forums.phpfreaks.com/topic/42224-simple-if-statement-question/ 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 Link to comment https://forums.phpfreaks.com/topic/42224-simple-if-statement-question/#findComment-204809 Share on other sites More sharing options...
Canman2005 Posted March 11, 2007 Author Share Posted March 11, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/42224-simple-if-statement-question/#findComment-204929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.