-Karl- Posted March 24, 2010 Share Posted March 24, 2010 Okay so I have: <?php $page = $_get['page']; if (isset($page['add'])) { //do add } if (isset($page['edit'])) { //do edit } So if the page is index.php?page=add, it will do the $page['add'] and if not the $page['edit']. I've probably done it wrong which is why it isn't working, but I've looked over the manual and it seems logical. What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/ Share on other sites More sharing options...
premiso Posted March 24, 2010 Share Posted March 24, 2010 PHP is CaSe SenSiTiVe $page = $_GET['page']; GET / POST / SESSION / COOKIES / SERVER all need to be in caps. Quote Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/#findComment-1031049 Share on other sites More sharing options...
-Karl- Posted March 24, 2010 Author Share Posted March 24, 2010 PHP is CaSe SenSiTiVe $page = $_GET['page']; GET / POST / SESSION / COOKIES / SERVER all need to be in caps. That works, but it shows both add and edit. Quote Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/#findComment-1031050 Share on other sites More sharing options...
andrewdav Posted March 24, 2010 Share Posted March 24, 2010 Try this <?php if (isset($_get['page'])) { if($_get['page']=='add') {//do add} if ($_get['page']=='edit') {//do edit} } ?> Quote Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/#findComment-1031051 Share on other sites More sharing options...
premiso Posted March 24, 2010 Share Posted March 24, 2010 <?php $page = isset($_GET['page'])?$_GET['page']:'index'; switch ($page) { case 'add': break; case 'edit': break; default: case 'index': break; } ?> I believe that is the type of logic you are after. Quote Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/#findComment-1031053 Share on other sites More sharing options...
-Karl- Posted March 24, 2010 Author Share Posted March 24, 2010 Try this <?php if (isset($_get['page'])) { if($_get['page']=='add') {//do add} if ($_get['page']=='edit') {//do edit} } ?> Works perfectly with GET not get Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/#findComment-1031056 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.