Gayner Posted November 22, 2009 Share Posted November 22, 2009 if ($_GET['God'] == "Enter") This works but if i add isset like this: if (isset($_GET['God']) == "Enter") then it wont read it it will skip it help ? Quote Link to comment Share on other sites More sharing options...
Errant_Shadow Posted November 22, 2009 Share Posted November 22, 2009 because isset() checks to see if that variable is set. So, if $_GET['God'] is set, then isset($_GET['God']) will translate to "true" but it won't give you the value of $_GET['God'] if you want to check to make sure $_GET['God'] is not only set, but set to something specific, use: if ($isset($_GET['God']) && $_GET['God'] == "Enter") so it checks to see if $_GET['God'] is set at all, and if it is (only if it is) it will then check the value. Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 22, 2009 Author Share Posted November 22, 2009 because isset() checks to see if that variable is set. So, if $_GET['God'] is set, then isset($_GET['God']) will translate to "true" but it won't give you the value of $_GET['God'] if you want to check to make sure $_GET['God'] is not only set, but set to something specific, use: if ($isset($_GET['God']) && $_GET['God'] == "Enter") so it checks to see if $_GET['God'] is set at all, and if it is (only if it is) it will then check the value. oh, lol ok thanks so i'll add the && wat about a | will that work too ? Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted November 22, 2009 Share Posted November 22, 2009 Here. if(isset($_GET['God']) && $_GET['God'] == "Enter") { // do something } James. Quote Link to comment Share on other sites More sharing options...
keeB Posted November 22, 2009 Share Posted November 22, 2009 wat about a | will that work too ? || means OR. You'd use it like so: <?php if ($my_mom == "ghetto" || $my_mom == "white trash")) { // if my mom is ghetto or white trash... $i = "cannot spell which is why I say 'wat'"; } ?> Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 22, 2009 Share Posted November 22, 2009 usually u check to see if the variable is there with $_POST (then u use isset.) with $_GET u can use to check if its there, if($_GET[God] != "") if u are just chekcing if the get verable equals ENTER u do not need to use isset or != "" Quote Link to comment Share on other sites More sharing options...
keldorn Posted November 22, 2009 Share Posted November 22, 2009 Gayner something else you do to make sure that $god is set before calling it. Welcome to the wonderful ternary operator. <?php // make $god equal $_GET['god'] if its set else make it empty "" $god = isset($_GET['god']) === true ? $_GET['god'] : ""; // you could add some filtering right there also // $god = isset($_GET['god']) === true ? mysql_real_escape_string(strip_tags($_GET['god'])) : ""; if($god == "Enter"){ // stuff } Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 22, 2009 Author Share Posted November 22, 2009 Gayner something else you do to make sure that $god is set before calling it. Welcome to the wonderful ternary operator. <?php // make $god equal $_GET['god'] if its set else make it empty "" $god = isset($_GET['god'] === true ? $_GET['god'] : ""; // you could add some filtering right there also // $god = isset($_GET['god'] === true ? mysql_real_escape_string(strip_tags($_GET['god'])) : ""; if($god == "Enter"){ // stuff } Thanks so much code for such little code i want to do, but i guess that's php, i love the terny operator tho thx Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 22, 2009 Share Posted November 22, 2009 like ni said just see if its equal to nothing its less of a hassel 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.