0
I’m trying to make a code to enter data into the database localhost
, but I’m having trouble inserting, and I don’t know why.
My database settings are correct and the tables are correct. The error is definitely in the code, so I would like to find out what the problem is:
<?php
include("admin/configs/config.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>Registro</title>
</head>
<body>
<div align="center">
<br><br><br><br><br><br><br>
<form action="" method="POST" name="form">
<input type="text" name="r_nome" placeholder="Nome">
<br><br>
<input type="text" name="r_usuario" placeholder="Usuário">
<br><br>
<input type="password" name="r_senha" placeholder="Senha">
<br><br>
<input type="submit" name="submit" value="Registrar">
</form>
</div>
</body>
</html>
<?php
if(isset($_POST["submit"])){
$nome = $_POST["r_nome"];
$usuario = $_POST["r_usuario"];
$senha = $_POST["r_senha"];
$foto = "uploads/";
if (empty($usuario) || empty($nome) || empty($senha)) {
echo "Preencha todos os campos!";
}else{
$query = "INSERT INTO usuarios (nome, usuario, senha, foto) VALUES ('$nome', '$usuario', '$senha', '$foto')";
}
}
?>
You are not running the query.
– Luiz Felipe