PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hey people. I have been trying to make a php include module type scriptwhich works from the $_get function. Everything works fine but is there any way of getting (see below) so that when i access ie. content.php?p=test directly it will redirect, or include content.php?p=test/index automatically, becouse currently if i acccess content.php?p=test it will be treated as a file, ie. content.php?p=test/.php. beocuse of the
<?php
include 'config.php';
$p=$_GET["p"];
if(empty($p))
{
include "index.php";
//i made this include a file home.php if you are usign this for a site navigation then u want the url to b: site.com not site.com?p=home
} else {
if((strlen($p) > 20) or (strlen($p) < 4) or (is_numeric($p))){
echo "$hackattempt";
} else {
if(file_exists("content\\".$p.".php")){
include 'includes/header.php';
include "content\\".$p.".php";
include 'includes/footer.php';
} else { echo"<center><b>404 Error</b><br /><br />The page you requested does not exist.</center>"; }
}
}
?>
I dont know how to solve this problem, thanks in advance!
I still suffer from the same problem. If i access "content.php?p=test" it will bring me to my 404. The only way of getting round this is to visit "content.php?p=test/index", but is there any way of getting "content.php?p=test" and keep my 404?
<?php
include 'config.php';
$p=$_GET["p"];
if(empty($p))
{
include "index.php";
//i made this include a file home.php if you are usign this for a site navigation then u want the url to b: site.com not site.com?p=home
} else {
if((strlen($p) > 20) or (strlen($p) < 4) or (is_numeric($p))){
echo "$hackattempt";
} else {
$filename = "content/$p.php";
if(file_exists($filename )){
include 'includes/header.php';
include $filename;
include 'includes/footer.php';
} else { echo"<center><b>404 Error</b><br /><br />The page you requested does not exist.</center>"; }
}
}
?>
<?php
include 'config.php';
$p=$_GET["p"];
if(empty($p))
{
include "index.php";
//i made this include a file home.php if you are usign this for a site navigation then u want the url to b: site.com not site.com?p=home
} else {
if((strlen($p) > 20) or (strlen($p) < 4) or (is_numeric($p))){
echo "$hackattempt";
} else {
$filename = "content/$p.php";
if(file_exists($filename )){
include 'includes/header.php';
include $filename;
include 'includes/footer.php';
} elseif(file_ exists('content/$p/index.php')):
include 'includes/header.php';
include 'content/$p/index.php';
include 'includes/footer.php';
} else { echo"<center><b>404 Error</b><br /><br />The page you requested does not exist.</center>"; }
}
}
?>
<?php
include 'config.php';
$p=$_GET["p"];
if(empty($p))
{
include "index.php";
//i made this include a file home.php if you are usign this for a site navigation then u want the url to b: site.com not site.com?p=home
} else {
if((strlen($p) > 20) or (strlen($p) < 4) or (is_numeric($p))){
echo "$hackattempt";
} else {
$filename = "content/$p.php";
$filenamedir = "content/$p/index.php";
if(file_exists($filename )){
include 'includes/header.php';
include $filename;
include 'includes/footer.php';
} elseif(file_ exists($filenamedir)){
include 'includes/header.php';
include $filenamedir;
include 'includes/footer.php';
} else { echo"<center><b>404 Error</b><br /><br />The page you requested does not exist.</center>"; }
}
}
?>
<?php
include 'config.php';
$p=$_GET["p"];
if(empty($p))
{
include "index.php";
//i made this include a file home.php if you are usign this for a site navigation then u want the url to b: site.com not site.com?p=home
} else {
if((strlen($p) > 20) or (strlen($p) < 4) or (is_numeric($p))){
echo "$hackattempt";
} else {
$filename = 'content/$p.php';
$filenamedir = 'content/$p/index.php';
if(file_exists($filename )){
include 'includes/header.php';
include $filename;
include 'includes/footer.php';
} elseif(file_ exists($filenamedir)){
include 'includes/header.php';
include $filenamedir;
include 'includes/footer.php';
} else { echo"<center><b>404 Error</b><br /><br />The page you requested does not exist.</center>"; }
}
}
?>