Hi guys here is a code for a simple dynamic website:
Index:
inc/test.php
inc/home.php
Now why does it say "undefined index: p" in the home page, but not the test page? Plz help to remove it thanks. P.S. I know its not so secure I am fixing it, but is struggling with this error and remember I have no MySQL database this is purely PHP.
Thanks in advance
Sup3rCow
Index:
Code:
<html>
<table width="70%" align="center">
<tr>
<td>
<h1>My Web Page</h1>
</td>
</tr>
</table>
<table width="70%" align="center">
<tr>
<td width="20%">
<b>
<a href="index.php">Home</a>
<a href="?p=test">Test</a>
</b>
</td>
<td width="80%">
<?php
$page = $_GET['p'];
if ($page)
{
$path = "inc/".$page.".php";
if (file_exists($path))
{
include ("inc/".$page.".php");
}
else
{
echo 'Sorry, the page does not exist';
}
}
else
{
include ('inc/home.php');
}
?>
</td>
</tr>
</table>
</html>
inc/test.php
Code:
<html>
This is my test page
</html>
inc/home.php
Code:
<html>
This is my home page
</html>
Now why does it say "undefined index: p" in the home page, but not the test page? Plz help to remove it thanks. P.S. I know its not so secure I am fixing it, but is struggling with this error and remember I have no MySQL database this is purely PHP.
Thanks in advance
Sup3rCow
Last edited: