Hi everyone I'm trying to make a dynamic web page with PHP and I have a problem with $_SERVER['PATH_INFO'], I think. Every time I press home or about it appends index.php.home or index.php.about to the url. Here is my code:
<body>
<div style="width:800px; height:auto;">
<nav>
<a href="index.php/home">home</a>
<a href="index.php/about">about</a>
</nav>
<?php
$path = substr($_SERVER['PATH_INFO'],1);
echo $path;
if($path==""){
$path = "home";
}
if($path == "home"){
?>
<h1> Home Page </h1>
<?php
}
elseif($path == "about"){
?>
<h1> About Page</h1>
<?php
}else{
?>
<h1> Page Not Found </h1>
<?php
}
?>
</div>
</body>
Could I have some help with this problem?
$_SERVER- you will find more information and even user-notes that help you to go around the very first corners. What does'ORIG_PATH_INFO'give you?<a href="/index.php/about">about</a>or<a href="/path/to/index.php/about">about</a>. This will overcome your issue.