0
I’m getting information from a select, which pulls the states and cities registered in the database. In the value of each select (city and state) is their id in the table (only this way to work with the function in AJAX). But at the time of entering I’m not managing to turn that state and city id into the name of the city (select * from cidade where id = $_post[cidade]
). By placing a mysqli_query
in the PHP variable and then try to insert it gives an error.
$cidade = $_POST['cidade'];
$estado = $_POST['estado'];
//Validando dados do formulário
if(!empty($nome) && !empty($endereco) && !empty($num) && !empty($CEP) && !empty($bairro) && !empty($cidade) && !empty($estado)){
//Caso todos os campos sejam preenchidos, insere os valores na tabela estabelecimento
mysqli_query($conectar, "INSERT INTO estabelecimento VALUES (NULL, '$nome', '$CNPJ', '$endereco',
'$num', '$comp', '$CEP', '$bairro', '$cidade', '$estado', 0)");
The first two records were entered manually into the database.
What is the error? the data is information you did not enter in the form?
– Bsalvo
It’s actually working, but I just wanted you to enter the name of the city instead of the id.
– Isac Moura