0
I believe it is not an error, more a ma structure in the checks of the pages recently adapted a friendly url on my site, then I decided to implemtar a search system with ajax, in the home of the site it works right as you can see in the image
however when I go to another page of the site and try to do a search, he adds to busca.php
and save my entire page as per the image
Someone knows what’s going on ?
index php.
include_once("sql/config.php");
if(isset($_GET['url'])){
$url = $_GET['url'];
$urlE = explode('/',$url);
}
if(isset($urlE[0])){
$arquivo = $urlE[0];
}elseif(isset($urlE[0]) || isset($urlE[1])){
$arquivo = $urlE[0];
$post = $urlE[1];
}
$paginas = array('contato');
//verifica se a pagina existe no meu diretorio
if(isset($arquivo) && in_array($arquivo,$paginas)){
include_once "includes/$arquivo.php";
echo "aqui";
}
//se nao existir nada na minha url, manda para a home
elseif(!isset($urlE[0])){
include_once "includes/home.php";
echo "aqui home";
}
//caso nao exista no meu diretorio, mais esteja cadastrado no banco de dados
else{
include_once "includes/generos.php";
echo "aqui generos";
}
is falling into the if calling the page generos.php
I changed my last else
even though it didn’t work
else{
if($urlE == 'busca'){
}else{
include_once "includes/generos.php";
echo "aqui generos";
}
}
before I was calling my pages only with include
then I thought the problem was this, I did a research and I found here an explanation about include
, include_once
, require
and require_once
that Maniero did, so I changed everything to include_once
, but did not solve my problem
Mayron, I think this index controller of yours is a little fuzzy. Probably (I don’t know if that’s it) the search screen is falling in more 1 IF and why it’s probably duplicating and causing bugs even in ajax. Give a few
echo "aqui";
inside ifs you’ll find the bug.– Andrei Coelho
@Andreicoelho really is falling into one of if, I don’t know what to do, would have some hiccup ?
– goio
I would need to better understand your url. There are ways you can show the url in the case that works and the url in the cases that the bug happens?
– Andrei Coelho
@Andreicoelho the search is falling in the last Else, no matter which url is in, this url that generates the page generos.php comes from the bank
– goio
I think the problem is here:
if($urlE == 'busca'){ ...
actually isif($urlE[0] == 'busca'){ ...
try like this.– Andrei Coelho
Because when you give a bang. It turns the string into an array.
– Andrei Coelho
@Andreicoelho same thing, has not changed anything, what strange
– goio
Let’s go continue this discussion in chat.
– Andrei Coelho