-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? 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. 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. 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} } ?> 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. 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. Link to comment https://forums.phpfreaks.com/topic/196362-isset-pages/#findComment-1031056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.