2
I have an error on my site, in the matter of UTF-8
If I use á
it goes to link as %E3%83%E2%A1
and printa in input as %e3%83%e2%a1
in hosting.
But on localhost it goes as ã¡
and comes back as %c3%a3%c2%a1
.
The codes I’m using are these:
To show the Code:
function mostrar($string) {
$string = str_replace('+', ' ', $string);
$string = utf8_decode($string);
return mb_strtolower( strip_tags( trim( $string ) ) );
}
To Send the Code:
function limpar($string) {
$string = str_replace(' ', '+', $string);
$string = utf8_encode($string);
return mb_strtolower( strip_tags( trim( str_replace('/', '', $string) ) ) );
}
Sending pro header('Location')
to appear in the site url:
if(isset($_POST['procm-p']) or isset($_POST['procm-s'])){
$pesquisa = strip_tags($_POST['procm-s']);
if(isset($pesquisa) and !empty($pesquisa)){
$link = $surl.'p/'.limpar($pesquisa);
header("Location: ".$link);
}else{
echo '<script>alert("Pesquisa Invalida");</script>';
}
}
Printando in input:
<input type="text" name="procm-s" value="<?php echo mostrar( $url[1] ); ?>" placeholder="Procurar Musicas" />
How is the form:
<div id="pesquisa2">
<form action="" enctype="multipart/form-data" autocomplete="on" method="post" name="procm">
<input type="text" name="procm-s" value="<?php echo mostrar($url[1]); ?>" placeholder="Procurar Musicas" />
<input type="submit" value="Procurar" name="procm-p" id="btn" />
</form>
</div>
I put the website on the air so you can see: http://searchable/
What I wanted was for him to be like a utf-8 encoded
and come back as utf-8
normal, but this does not happen.
And if you notice as I said above, it has an immense difference between my localhost
and my hospedagem
.
You know what? I’m using utf8_encode()
and utf8_decode()
and even header('Content-Type: text/html; charset=utf-8');
.