Registration in php

1

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.

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;

      }
   }

* Insert code to mysql database

    
asked by anonymous 04.05.2018 / 21:14

1 answer

-2

You have ; left over there:

$sql = "INSERT INTO usuarios (usuario, senha) VALUES ('$g_user', '$g_pass');";

Replace with:

$sql = "INSERT INTO usuarios (usuario, senha) VALUES ('$g_user', '$g_pass')";

[RESOLVED] Field type in table was incorrect

    
04.05.2018 / 21:18