0
<?php
include_once("conexao.php");
$nome = $_POST['nome'];
$email = $_POST['email'];
$senha = $_POST['senha'];
$sql = ("INSERT INTO `usuarios`(`nome`, `email`, `senha`) VALUES ([$nome],[$email],[$senha])");
$result = mysqli_query($conn, $sql);
?>
<html>
<head>
<title>Central de Estudos | Cadastro</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/java.js"></script>
<style>
body {
background-image: url("imgs/bg.jpg");
background-repeat: no-repeat;
font-family: "Roboto", sans-serif;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<div class="login-page">
<div class="form">
<h3 style="font-size: 14px;">CENTRAL DE ESTUDOS | CADASTRO</h3>
<form class="login-form" name="loginform" method="post" action="">
<input type="text" placeholder="Nome" name="nome"/>
<input type="email" placeholder="Email" name="email" />
<input type="password" placeholder="Senha" name="senha" />
<button type="hidden" name="entrar" value="cadastrar">Cadastrar</button>
<p class="message"> Desenvolvido por: Marcos A. Massini</p>
</form>
</div>
</div>
</body>
</html>
In
$sql
, swap out the[]
for{}
. To confirm if this is really the problem, just check the value of$sql
before and after the change.– Woss
I changed it, but it still wasn’t
– Marcos A. Massini
My connection is like this.
– Marcos A. Massini
<?php $server = "localhost"; $user = "root"; $password = ""; $dbname = "register"; $Conn = Mysqli_connect($server, $user, $password, $dbname) or print (mysql_error()); if(!Mysqli_connect($server, $user, $password)) { echo "Error when connecting"; } ?>
– Marcos A. Massini
And what was the result when displaying the value of
$sql
? It seems that quotes are missing in the values there too.– Woss
None, it shows no error, just does not save the data in mysql.
– Marcos A. Massini
It is not the mistake, but rather putting one
var_dump($sql)
in your code. And you are already in contact with me here.– Woss
So I had understood something else, he printo me this:
– Marcos A. Massini
string(105) "INSERT INTO
usuarios
(nome
,email
,senha
) VALUES (Marcos Augusto Masini, [email protected],81810338)"– Marcos A. Massini
just correct your query to
$sql = "INSERT INTO usuarios (nome, email, senha) VALUES ('$nome', '$email', '$senha')";
that will work.– user60252