Presto-X Posted April 11, 2007 Share Posted April 11, 2007 How would I do this, I'm trying to use if something or something do the same thing with out having to put all the same code in twice. if ( $page == "update" or "new" ){echo "Saving...";} I have been fooling around with this for a day and it is driving me nuts I did not know what to search for I was not coming up with anything of any use. I tride: $page == "update","new" $page == "update" or "new" $page == 'update' or 'new' Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 11, 2007 Share Posted April 11, 2007 <?php if (($_GET['page'] == 'update') | ($_GET['page'] == 'new')) { echo'Looks like it works'; } ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 11, 2007 Share Posted April 11, 2007 Also, never code asuming that register_globals will be set to "on" in the PHP configuration. Newer versions of PHP have it set to "off" by default....and rightly so. Quote Link to comment Share on other sites More sharing options...
Dragen Posted April 11, 2007 Share Posted April 11, 2007 should there be || instead of |? <?php if (($_GET['page'] == 'update') || ($_GET['page'] == 'new')) { echo'Looks like it works'; } ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 11, 2007 Share Posted April 11, 2007 One should work fine in this case. Quote Link to comment Share on other sites More sharing options...
Presto-X Posted April 11, 2007 Author Share Posted April 11, 2007 Thank you guys so much it looks like it is working great now, I'm going back cleaning out alot of the if and elses in there lol thanks guys. Hay Caesar what do you mean by "register_globals will be set" ? I'm new to php and I'm still learning all of the terms. Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 11, 2007 Share Posted April 11, 2007 If you're sending values using urls such as: http://somesite.com/index.php?page=pr0n Then you want to make sure that you retrieve the values by using $_GET, instead of writing your code to look for $page. When you do that, you're asuming the server the site is on, has register_globals set to "on". And once you move your script somewhere else, it's likely it will stop working. So your code should look something like: <?php $page = $_GET['page']; if (($page == 'pr0n') | ($page == 'nekkid')) { echo'You dirty dirty boy...*snicker*'; } ?> Good luck and happy coding! Quote Link to comment Share on other sites More sharing options...
Presto-X Posted April 11, 2007 Author Share Posted April 11, 2007 ahh cool thanks for the info, ya I have a hole list of those at the top of my code $refresh = $_GET['refresh']; $state = $_GET['state']; $page = $_GET['page']; $dealerid = $_GET['dealerid']; like that right? 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.