0
I have a problem when I try to insert from a form
<form method="post" action="../../controller/inserirContato.php">
<label for="name" class="nameLabel">Meu nome é: </label>
<input id="name" type="text" name="nome" placeholder="Seu nome...">
<label for="email" class="emailLabel">Meu e-mail é:</label>
<input id="email" type="text" name="email" placeholder="Seu e-mail...">
<label for="titulo">Estou precisando de: </label>
<input id="subject" type="text" name="titulo" placeholder="O que deseja...">
<label for="message" class="messageLabel">Minhas observações são: </label>
<textarea id="message" name="obs" placeholder="observações..."></textarea>
<button type="submit" name="enviar">Enviar</button>
</form>
the php file I made, this is it.
include '../config/PDOUtil.php';
$con = new PDOUtil();
$nome = $_POST['nome'];
$email = $_POST['email'];
$titulo = $_POST['titulo'];
$obs = $_POST['obs'];
$sql = 'INSERT INTO contato (nome, email, titulo, obs) VALUES (:nome, :email, :titulo, :obs)';
try {
$recebeConexao = $con->conectar()->prepare($sql);
$recebeConexao->bindValue(':nome', $email);
$recebeConexao->bindValue(':email', $email);
$recebeConexao->bindValue(':titulo', $titulo);
$recebeConexao->bindValue(':obs', $obs);
$recebeConexao->execute();
} catch (PDOException $ex) {
echo "ta dando pau";
}
thank you.
I’m not sure, but it assigns the prepare value to a variable and then executes it with it, e.g.: $Connection = $con->connect(); $Stmt = $connection->prepare(sql); $stmt->execute();
– Thiago
in
bindValue(':nome'
pass$nome
and not$email
.– rray
For more details of the error, give a
$ex->getStackTrace()
and stick it here.– Rodrigo Rigotti