Jump to content

Dynamic content on my index.php


Dood77

Recommended Posts

I'm currently using an index.php that displays the title, menu etc. and grabs a string from the address (/index.php&content=*blah*) to get the content for the page externally using include. (I don't have the code with me at the moment, I forgot it at home)

It works similarly to this:

<body>
<table>
<tr><td>
[menu]
</td>
<td>
<?php
$content = $_get["content"] . ".htm"
include($content)
?>
</td></tr>
</table>

The syntax is probably wrong there but thats not my issue. It works fine, but the menu I have is flash and whenever I click a link on it the whole page has to reload and the flash has to reload and it flashes (no pun intended) white. I realize this isn't really a php problem per se, but I figure you guys can help anyway, maybe theres a better way to dynamically load the content in the page without having to reload all the other stuff? Before I decided to go with php I was using javascript to dynamically change the src attribute to an iframe, but the iframe height can't very easily be calculated and changed dynamically...

So, yeah, responses appreciated and all that ;)

Link to comment
Share on other sites

only 1 of loading pages, without changing pages... ajax...

 

p.s. thats a VERY unsecure way of doing it

Hm, I don't know why ajax didn't occur to me but I'll look into it...

And by very insecure you mean...?

Link to comment
Share on other sites

If you still want to do it like that, you can do:

 

$content = $_GET['content'];
//$content = mysql_real_escape_string($content);
//only if you're pre-connecting to a database
if($content){
$content_new = "$content.htm";

if(file_exists($content_new)){
include "$content_new";
}else {
echo "This file does not exist";
}
}

Link to comment
Share on other sites

I'm not understanding what you're doing here... checking to see if the content loaded is already loaded? I already have an if statement that checks to see if the file is there, and redirects if its not.

Link to comment
Share on other sites

Yeah, like I said, I didn't have the original code with me at the moment.

But actually I do now:

<head>
<?php
$content = $_GET["content"];
?>
</head>
<body>
<?php
if (strlen($content) == 0){
header ("Location: index.php?content=intro");
} elseif (!file_exists($content . ".htm")){
$content = "error";
}
include($content . ".htm");
?>
</body>

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.