-1
So, guys, I’m trying to input some data from a log screen into the database, but when I input it, the special characters click into the database. Follow the code in php:
<?php
header('Content-Type: text/html; charset=utf-8');
$fullName = $_POST["name"];
$senha = $_POST["password"];
$confirmSenha = $_POST["confirmPassword"];
$rua = $_POST["endereco"];
$numero = $_POST["numero"];
$bairro = $_POST["bairro"];
$conn = mysqli_connect("localhost", "usuario", "senha", "teste");
if (!$conn) {
echo "Failed to connect with MySQL" . mysqli_connect_errno();
}
if ($senha == $confirmSenha) {
$sql = "INSERT INTO usuario (fullName,senha,rua,numero,bairro) VALUES('$fullName','$senha','$rua','$numero','$bairro')";
if (mysqli_query($conn, $sql)) {
echo ("<script>alert('Registrado com sucesso!!');</script>");
} else {
echo "Erro";
}
} else {
echo ("<script>alert('Senhas não são iguais.');window.location.href('telaRegistro.html');</script>");
}
In this case, the id user 3 and 5 were manually inserted by a query in the heidisql itself, the other ones that are bugged are inserted through the code.
Thanks, buddy! Solved the bug.
– João Pedro
Use the tools to thank, there is no need to write thank you, however, for nothing!
– rengaw