1
I’ve made a lot of changes to the code and I’ve researched several sites and nothing has solved my problem!
HTML code:
<div class="w3-container w3-padding-32" id="about">
<h3 class="w3-border-bottom w3-border-light-grey w3-padding-16">Sobre o site</h3>
<p>
<?php
$sql_sobre = "SELECT sobre_home FROM campos";
$sql_sobrequery = mysqli_query($conn, $sql_sobre) or die (mysqli_error($conn));
$row = mysqli_fetch_row($sql_sobrequery);
$decoded = utf8_encode($row[0]);
echo $decoded;
?>
</p><div id="edicao" hidden><form method="POST" action="confirmarEdicao.php"><textarea class="textboxEditar" name="edicaoSobreHome"><?php echo $decoded ?></textarea> <input class="buttonEditar" type="submit" value="Confirmar"></form></div>
PHP code:
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$db = "aeac";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $db);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error);
}
else{
if (isset($_POST['edicaoSobreHome'])){
$editar = $_POST['edicaoSobreHome'];
$editar_encoded = utf8_encode($editar);
$query = "UPDATE campos SET sobre_home = '$editar_encoded'";
$result = mysqli_query($conn, $query);
}
}
The purpose of this div is to edit the text on the site itself through a hidden textarea that appears after clicking a button with a JS function.
My problem here is that by inserting special characters as letters with accents, the text in the database does not recognize the characters and returns text as the following:
"pode encontrar informação sobre as"
How to header your html?
– David
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-Scale=1">
– RedCandy
What table charset in the database?
– David
utf8_spanish_ci
– RedCandy
Dear(a) Redcandy do not use UTF8_DECODE OR UTF8_ENCODE, follow the instructions: https://answall.com/a/43205/3635
– Guilherme Nascimento