2
Hello, all good ? , I have a problem in performing data insertion in a MYSQL database. When I type a password in my form, for example: metas123, or any other password, it stores the value 0, instead of the string typed, and I really have no idea why this happens... if you can help me thank you very much.
if (!empty($_POST['user']) and !empty($_POST['pass'])) {
$g_user = mysqli_real_escape_string($conn, $_POST['user']);
$g_pass = $_POST['pass'];
$sql = "INSERT INTO usuarios (usuario, senha) VALUES ('$g_user', '$g_pass');";
$executa = mysqli_query($conn, $sql);
switch ($executa) {
case true:
header("Location: login_page/index.php?cadastro=sucesso");
break;
default:
header("Location: index.php?cadastro=erro");
break;
}
}
*Insertion code to mysql database
thanks kk, first time I touch the stackoverflow, sorry anything
– Alan
This question could only be answered if you put the column types of your table and the types of how they are being sent .
– user60252
What values comes from
$_POST
? They are correct ? Test withvar_dump($_POST);
and confirm that you have the correct values. Then do what Leo said and put the table structureusuarios
on the question to make sure that the types are correct.– Isac
opa, all good Isac? , admire your attention, but fortunately already solved the problem, the type of the field in the password table was marked as INT.
– Alan