PHP _GET, File Exists and include
Posted: Tue Feb 07, 2012 10:44 am
Hi Guys,
This is my first post on this board, but I'm quite sure it won't be the last
Well, I'm totally new at PHP Programming, so I could use some advice around some stuff. Right now i'm making a simple menu where all my content should get loaded into a <div>. it works perfectly, but the entire site refreshes everytime I click my links. can somebody please help me on this one? it's because i'm also running a javascript with a image rotator, and it resets everytime I press one of these links.
my code is currently quite simple. (I'm not that much into security right now, but I'll look into that when I get a basic understanding of php)
the a href goes like this
and the code in the targeted div goes like this
This is my first post on this board, but I'm quite sure it won't be the last
Well, I'm totally new at PHP Programming, so I could use some advice around some stuff. Right now i'm making a simple menu where all my content should get loaded into a <div>. it works perfectly, but the entire site refreshes everytime I click my links. can somebody please help me on this one? it's because i'm also running a javascript with a image rotator, and it resets everytime I press one of these links.
my code is currently quite simple. (I'm not that much into security right now, but I'll look into that when I get a basic understanding of php)
the a href goes like this
Code: Select all
<a href="index.php?page=content/news">Image</a>and the code in the targeted div goes like this
Code: Select all
$page = $_GET["page"];
if (file_exists($page . ".php"))
{
include ($page . ".php");
}
else
{
echo ("404 Error - File Doesn't Exist");
}