I am trying to make a code to insert data into the localhost
database, however I am not able to insert, and I do not know why.
My database settings are correct and the tables are also correct. The error for sure is 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')";
}
}
?>