0
Hello friends I am very layman in PDO and I would like the help of friends to try to create an INSERT that registers a font name in the BD source table. Next, I created this code below, based on the UPDATE code that is working:
<form name="enter" method="post" action="" enctype="multipart/form-data">
<?php
if(isset($_POST['enter'])){
$pdo = new PDO('mysql:host=localhost;dbname=site', "root", "");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare ('INSERT INTO fontes (font) VALUES (:font)');
$stmt->execute(array(':font' => $font));
echo
"<meta http-equiv='refresh' content='0; URL= ../cadastros/cad_fonte.php'>
<script language='javascript'>
window.alert('Dados alterados com sucesso!');
</script>";
}
?>
<h3>Caso a fonte desejada não esteja listada, cadastre-a agora!</h3><br />
<input type="text" name="font" value="" />
<input type="submit" name="enter" value="Cadastrar" />
I ask friends to help me make a code that works so I can register.
From now on my thanks.
Which error was found?
– Vinícius Gobbo A. de Oliveira
Friends, I found out why I was unable to register the source. This line was missing from the code. '$font = $_POST['font'];' .
– Murilo Cabral