Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-01-2004, 04:04 PM Dynamic Webpage...
Skilled Talker

Posts: 87
Location: New York
Trades: 0
Hey i asked this question before but didnt get the right anwsers so im going to try again, maybe someone can write this code up so i can run it and see how it works...

Ok i want to make my webpage so that on the main.php i can click on a nav link and it will change the content but not the actual page, so that it is viewing the layout of the page somewhere else... do you know what i mean?

page.com?content=whatever
something like that after i click on the link...
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
 
Register now for full access!
Old 04-01-2004, 05:15 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Trades: 0
OK, here's some really simple code. You'd need to add some security measures to stop people messing about with your server through invalid requests to the script, but heres the basics:
PHP Code:
<?
// Set Path to Datafiles
$fullpath="/home/username/public_html/datafiles/";

// Generate path to file to open. Get filename from content argument
$filename $fullpath.$_GET['content']'.txt';

// Load file from server
$fp fopen($filename"r");
$mainpage fread($fpfilesize($filename));
fclose($fp);
?>

YOUR HTML CODE FOR PAGE IN HERE

Wherever you want the content to appear
<? echo $mainpage?>

YOUR HTML CODE FOR PAGE IN HERE
This code will load an appropriate text file from your server e.g:
Request page: www.yoursite.com/page.php?content=mainpage
it would load
www.yoursite.com/datafiles/mainpage.txt
and insert that text into the appropriate place on your design.

As I said, this is VERY insecure in its current form. You would have to build in checking to ensure users could only read from the datafile directory, and that any server commands were removed from input.

There are more advanced methods using databases (MySQL is good) which allow more flexibility. Have a look at http://www.freewebmasterhelp.com/tutorials/phpmysql/ for more information (and to see one such system in operation).
__________________

Please login or register to view this content. Registration is FREE
- Everything a webmaster needs - for free

Please login or register to view this content. Registration is FREE
- Free web hosts reviewed and rated

Please login or register to view this content. Registration is FREE
- Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile
 
Old 04-01-2004, 08:37 PM
WaHoOoO!'s Avatar
Mentally Unstable Tugboat Captain

Posts: 797
Name: Chad
Location: /usr/bin/perl
Trades: 0
I've found another way that is really simple as well, not sure about the whole security issue though...

Build your layout. Wherever you want your page content to be, put the following code:

PHP Code:
<?php 
if(!$id){ $id="home";} // This line signifies the default if no other  id is selected
if($id == home) include("news/news.txt"); // The first part says what the id is, and the second part says what to include
if($id == siteinfo) include("info/index.html"); 
if(
$id == chat) include("chat/index.php");
?>
Get the idea? When making your link table, just make stuff that says to link to "index.php?id=whatever". Hope this helps.
__________________
He's baaaaaaaack....
WaHoOoO! is offline
Reply With Quote
View Public Profile Visit WaHoOoO!'s homepage!
 
Old 04-01-2004, 11:25 PM
Skilled Talker

Posts: 87
Location: New York
Trades: 0
thanks WaHoOoO!, i was wondering if you could help me again, if i click in a link within the table it wont work i was wondering if there is anyway to fix that
NYChaoS is offline
Reply With Quote
View Public Profile Visit NYChaoS's homepage!
 
Old 04-02-2004, 03:55 AM
Ultra Talker

Posts: 377
Trades: 0
Just to mention... You may also do like this:
(for example call this file nav.php)
<?
include ("head.php");
include ("link.php");
...
...
include ("$content.php");
?>

and place a link like that <a href=nav.php?content=chat> or smth like this...
__________________
andrews_john

Please login or register to view this content. Registration is FREE
andrews_john is offline
Reply With Quote
View Public Profile Visit andrews_john's homepage!
 
Old 04-02-2004, 08:07 AM
Calash's Avatar
Super Talker

Posts: 104
Trades: 0
One thing you do not want to do is have a variable passed from the URL decide what page you will go to. It is a high security risk since you can put another path there and run a script that is not even on your site. Alwayse check your varable before processing it.

The switch statment works very well in this situation

PHP Code:
switch ($page)
{
case 
"Home":
include(
"index.htm"); 
break;

case 
"about":
include(
"about.htm"); 
break;

default:
include(
"/index.htm);
break;

My syntax may be a bit rusty...it is early
__________________

Please login or register to view this content. Registration is FREE
Calash is offline
Reply With Quote
View Public Profile Visit Calash's homepage!
 
Old 11-20-2006, 05:57 PM Re: Dynamic Webpage...
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
im am interested in the same thing anyone help?
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 11-21-2006, 02:32 PM Re: Dynamic Webpage...
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Using frames too!

or use this

PHP Code:
<? if ($page == ""$page "news";

if (!
file_exists($page.".php")) $page "inc/error";

include(
$page.".php");

?>
feraira is offline
Reply With Quote
View Public Profile
 
Old 11-21-2006, 03:41 PM Re: Dynamic Webpage...
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
does css not work in php pages? i am trying to make a page using the ? thingy (real tech language) and it has no css so it looks crap basically wonderd why. the page is http://dansgalaxy.co.uk/test/index.php try http://dansgalaxy.co.uk/test/index.php?page=contact as a example its crap page i know anyone help?


(edit 26/06/07: please dont judge me by this.. i know more now...)

Last edited by dansgalaxy; 06-26-2007 at 01:01 PM..
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-14-2007, 03:11 PM Re: Dynamic Webpage...
Skilled Talker

Latest Blog Post:
My book update
Posts: 97
Name: Eric
Location: Las Vegas
Trades: 0
Quote:
Originally Posted by feraira View Post
Using frames too!

or use this

PHP Code:
<? if ($page == ""$page "news";

if (!
file_exists($page.".php")) $page "inc/error";

include(
$page.".php");

?>
Frames are not good from an SEO's point of view. I would go with the switch statement above.
__________________

Please login or register to view this content. Registration is FREE

Eric - M
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
peanutpad is offline
Reply With Quote
View Public Profile Visit peanutpad's homepage!
 
Reply     « Reply to Dynamic Webpage...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30932 seconds with 12 queries