The data are not recorded in the database, but it appears that the registration was carried out successfully

Asked

Viewed 32 times

1

inserir a descrição da imagem aqui

<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "tomorrow";
$conexao=@mysqli_connect($host, $user, $pass) or die(mysqli_error());
mysqli_select_db($conexao,$db) or die(mysqli_error());
?>

<?php
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$sql=mysqli_query($conexao,"INSERT INTO usuarios(username, email, password)VALUES('$username', '$email', '$password')");
echo "<center><h1>Cadastro realizado com sucesso</h1></center>";
mysqli_close($conexao);
?>
  • Remove the @ to check for errors; The function mysqli_error after the method mysqli_connect is incorrect, the correct is mysqli_connect_errno; After mysqli_query add mysqli_error to check whether the query is correct; the message is showing because you have not added a if to check whether the query was successfully executed; The function mysqli_error precise parameter $conexão etc..

  • there is no way to comment with the code to help me more please men

  • 1

    In the database the field is written "emai" and in PHP is "email".

  • Why don’t you test the query before showing that it was successfully inserted? Use the G-ZUIS love control structures! And why are you using the tag center? Use the brand name too.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.