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' Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/ 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226409 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. Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226420 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226421 Share on other sites More sharing options...
Caesar Posted April 11, 2007 Share Posted April 11, 2007 One should work fine in this case. Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226423 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. Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226428 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! Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226432 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? Link to comment https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/#findComment-226437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.