dezkit Posted February 24, 2008 Share Posted February 24, 2008 How do i make so there is like &type=1234 after the $page=="home" <?php $page = $_GET["page"]; if (!$page) { include "/site/home.php"; } else if($page=="home") { include "/site/home.php"; } else if($page=="events") { include "/site/events.php"; } else if($page=="employment") { include "/site/employment.php"; } else if($page=="gallery") { include "/site/gallery.php"; } else if($page=="links") { include "/site/links.php"; } else if($page=="djs") { include "/site/djs.php"; } else if($page=="vip") { include "/site/vip.php"; } else if($page=="forum") { include "/site/forum.php"; } else if($page=="contact") { include "/site/contact.php"; } else { echo "<b><h1>404 Error</h1></b>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/ Share on other sites More sharing options...
nethnet Posted February 24, 2008 Share Posted February 24, 2008 You wouldn't need to, if I understand what you're trying to do correctly. Just set the &type=1234 bit to a variable, and then you will be able to use it in any script you include. <?php $page = $_GET["page"]; $type = $_GET["type"]; if(!$page) {include "/site/home.php"; } else if($page=="home") { include "/site/home.php"; } else if($page=="events") { include "/site/events.php"; } else if($page=="employment") { include "/site/employment.php"; } else if($page=="gallery") { include "/site/gallery.php"; } else if($page=="links") { include "/site/links.php"; } else if($page=="djs") { include "/site/djs.php"; } else if($page=="vip") { include "/site/vip.php"; } else if($page=="forum") { include "/site/forum.php"; } else if($page=="contact") { include "/site/contact.php"; } else { echo "<b><h1>404 Error</h1></b>"; } ?> So any page you include through your if statement will be able to use the $type variable. There is no need to pass it through the URL of the include function. Theo Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/#findComment-474921 Share on other sites More sharing options...
dezkit Posted February 24, 2008 Author Share Posted February 24, 2008 great code thanks alot, i will use it... but i also want so if www.example.com/index.php?view=home will say HOME but www.example.com/index.php?view=home&postID=23023 will say SOMETHING thanks alot if you answer Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/#findComment-474926 Share on other sites More sharing options...
dezkit Posted February 24, 2008 Author Share Posted February 24, 2008 bump before i go to sleep Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/#findComment-474945 Share on other sites More sharing options...
wildteen88 Posted February 24, 2008 Share Posted February 24, 2008 in home.php just check to see if the postID variable exists, if it does display what you want, <?php // see if postID url parameter exists and holds a number if(isset($_GET['postID']) && is_numeric($_GET['postID'])) { echo 'Display Something else<br />postID: ' . $_GET['postID']; } else { echo 'Display Homepage'; } ?> Also I'd use a switch/case rather than an if/elseif/else statement for displaying the page: <?php if(isset($_GET['page']) && !empty($_GET['page'])) { $page = $_GET['page']; switch($page) { case 'home': case 'events': case 'employment': case 'gallery': case 'links': case 'djs': case 'vip': case 'forum': case 'contact': include './site/' . $page . '.php'; break; default: die('404 Error - Page does not exist'); } } else { die('404 Error - Page does not exist'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/#findComment-475028 Share on other sites More sharing options...
dezkit Posted February 24, 2008 Author Share Posted February 24, 2008 i have no clue about what you just said lol, im new to php but anyways, thanks for help! Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/#findComment-475120 Share on other sites More sharing options...
wildteen88 Posted February 25, 2008 Share Posted February 25, 2008 If you do not understand the code, then I highly recommend that you learn the basics of PHP. I have not used any advanced code for the above scripts. Just play with them, if it breaks undo what changes you made. Quote Link to comment https://forums.phpfreaks.com/topic/92683-php-help/#findComment-476148 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.