0
Hello!
I have a question. I would like to create a file external to the menu of a site that is responsible for making the link between the pages, but I’m having a lot of difficulty executing. I’m starting with PHP now...
For example:
My menu has:
<a class="nav-link" href="./r.php?codigo=0" id="hl">Home</a>
<a class="nav-link" href="./r.php?codigo=1" id="hl">Quem Somos</a>
<a class="nav-link" href="./r.php?codigo=2" id="hl">Textos</a>
<a class="nav-link" href="./r.php?codigo=3" id="hl">Contato</a>
In the r.php file I am using the superglobal $_GET to get this information:
<?php
$link = $_GET['codigo'];
$endereco = array("./index.php","./quemsomos/index.php","./textos/index.php","./contato/index.php");
header('location: ' . $endereco[$link]);
?>
The first one works, because the r.php file is in the root folder, next to the first index.php. The others can’t find the file and I’m having a hard time doing it.
Had read that './' does the search from the root folder of the application, but is not working. Any hint?
Thank you in advance.
I’ve been researching and doing something similar to this. And another, I’ve added this same logic to a page that dynamically shows the texts/posts. Thanks for the help!
– jezq