don't want iframes
Moderator: Moderators
don't want iframes
i don't want to use iframes, is there still a way to display content from a different page on the main page? i can use php scripts if neccessary.
Code: Select all
Top of page/navigation
<div>
<? include "page_to_be_displayed.html(or .php)"; ?>
</div>
Bottom stuff like copyright etc.
you can format that however you want. My page is as follows (well on of my pages ):
Code: Select all
<?
session_start();
include "db.php";
function content()
{
switch( $_GET['id'] ) {
case '1' :
include 'general.php';
break;
default:
include 'index.php';
break;
}
}
/*function buy()
{
switch( $_GET['action'] ) {
case 'buy' :
include 'buy.php';
break;
default:
include 'index.php';
break;
}
}
*/
?>
<html>
<head>
<title>.:`~Infinite Opportunities~`:.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%">
<tr>
<td>
<img src="../images/banner.gif">
<br />
</td>
</tr>
<tr>
<td>
<table width="65%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<TABLE WIDTH=173 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<IMG SRC="../images/link_01.gif" WIDTH=173 HEIGHT=22 ALT=""></TD>
</TR>
<TR>
<TD background="../images/link_02.gif" width="173" height="20" style="background-repeat: repeat-y;">
<div width=170 style="position: relative; left: 3;">
<?
include "../links.php";
?>
</div>
<!--<IMG SRC="../images/link_02.gif" WIDTH=173 HEIGHT=20 ALT="">--></TD>
</TR>
<TR>
<TD>
<IMG SRC="../images/link_03.gif" WIDTH=173 HEIGHT=10 ALT=""></TD>
</TR>
</TABLE>
</td>
<td valign="top">
<TABLE WIDTH=570 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<IMG SRC="../images/content_01.gif" WIDTH=570 HEIGHT=30 ALT=""></TD>
</TR>
<TR>
<TD background="../images/content_02.gif" WIDTH=570 HEIGHT=52 style="background-repeat: repeat-y;">
<div width=567 style="position: relative; left: 3;">
<?
content();
//buy();
?>
</div>
<!--<IMG SRC="../images/content_02.gif" WIDTH=570 HEIGHT=52 ALT="">--></TD>
</TR>
<TR>
<TD>
<IMG SRC="../images/content_03.gif" WIDTH=570 HEIGHT=30 ALT=""></TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
thats pretty much a suped up version.
basically, it checks for the HTTP variable 'id' (http://www.afdafasf.com/home.php?id=1)
if and only if id = 1 will the page general.php be displayed. otherwise index.php will be displayed (default).
All of the html is just the 'pretty' part of the layout.
If that doesn't help then post here and i will simplify it(im just too lazy to type more right now).
-
stoodder
- Honorary Member

- Posts: 169
- Joined: Sat Jun 05, 2004 6:30 pm
- Location: Milwaukee, Wisconsin
- Contact:
just for a short script to include any page from the address bar(for exampel if you have ( http://www.blah.com?page=mypage1 ) i use
put that inside of your html where you want the pages to show up
i really hope that helps, if you need anymore help just ask, IM me or something
Code: Select all
<?php
$defPage = "Put Default Page Here"; // default page if others arent valid
$ext = ".php"; // your default extention, such as .html or . php
$page = isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : (isset($HTTP_POST_VARS['page']) ? $HTTP_POST_VARS['page'] : $defPage);
if(file_exists($page . $ext))
{
include($page . $ext);
}
else
{
include($defPage . $ext);
}
unset($page, $defPage, $ext);
?>
put that inside of your html where you want the pages to show up
i really hope that helps, if you need anymore help just ask, IM me or something
since we're on the topic (kinda
) of not all hosts doing the same thing i thought i would say that $_GET['whatever'] might not work. Do what stoodder did and use $HTTP_GET_VARS['whatever']. The main reason i don't do what stoodder did (the pagename in the url "www.blah.com?page=mypage1") is because then the user can try going to mypage1.php/html/htm/etc and the layout would be messed up. Then you would have to do some other coding to prevent that...
-
stoodder
- Honorary Member

- Posts: 169
- Joined: Sat Jun 05, 2004 6:30 pm
- Location: Milwaukee, Wisconsin
- Contact:
unclekyky wrote:since we're on the topic (kinda) of not all hosts doing the same thing i thought i would say that $_GET['whatever'] might not work. Do what stoodder did and use $HTTP_GET_VARS['whatever']. The main reason i don't do what stoodder did (the pagename in the url "www.blah.com?page=mypage1") is because then the user can try going to mypage1.php/html/htm/etc and the layout would be messed up. Then you would have to do some other coding to prevent that...
yep i totally agree, that an offsite user can use php injection to hack asite, ive been tyring to expirment with phph injection(not to hack a site but for security reasons) i guess what i would do to fix that is add right after the $page =
add
$page = htmlspecialchars($page);
then also add into the if statement
if(file_exists($page) && !preg_match("/:\/\//", $page)
the first part gets rid of any unwanted html characters or slashes that might mess with your code and the second part in the preg_match look for :// (such as in http:// or ftp://) to make sure the user isnt trying to grab a file off of another site
-
Hunter Lupe
- Administrator

- Posts: 1140
- Joined: Mon May 31, 2004 1:36 pm
- Contact:
Re: don't want iframes
kwo_dude wrote:i don't want to use iframes, is there still a way to display content from a different page on the main page? i can use php scripts if neccessary.
You can't do it in the same way as iframes -- the browser will have to reload the whole page to update a part of it (so there's no easy "open this page in this space" without iframes).
$HTTP_GET_VARS (PHP 3, 4) is superceded by $_GET (PHP 4, 5). If you really want to do your homework, check which one is set (and not just lock your script to older versions of PHP).
Filtering :// is clever, but you'll have to filter all the slashes to make anything even relatively secure (if both your indexes are index.php, you can cause an infinite include in a rather nasty way).

Will you stop with the honour stuff?
-
stoodder
- Honorary Member

- Posts: 169
- Joined: Sat Jun 05, 2004 6:30 pm
- Location: Milwaukee, Wisconsin
- Contact:
thus hunter proves me wrong XD, well i guess another fast sollution i have is to use a switch statement like unclekyky said lol the only problem i have with that is you always have to update it when you add new pages. Otherwise if you dont feel liekusing an switch statement, to stop them from reincluding index.php do somethng like this:
$page = strtolower($page);
if($page=="index")
{
$page = $defpage;
}
so your final code shoudl look something like this:
hopefully that is all, anyone see any others?
$page = strtolower($page);
if($page=="index")
{
$page = $defpage;
}
so your final code shoudl look something like this:
Code: Select all
Code:
<?php
$defPage = "Put Default Page Here"; // default page if others arent valid
$ext = ".php"; // your default extention, such as .html or . php
$page = isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : (isset($HTTP_POST_VARS['page']) ? $HTTP_POST_VARS['page'] : $defPage);
$page = htmlspecialchars($page);
$page =strtolower($page);
if($page == "index")
{
$page = $defpage;
}
if(file_exists($page . $ext) && !preg_match("/:\/\//", $page))
{
include($page . $ext);
}
else
{
include($defPage . $ext);
}
unset($page, $defPage, $ext);
?>
hopefully that is all, anyone see any others?


