0
Why does the following code not enter? Someone experienced can tell me the code below does not present an error yet does not insert in the bank.
<form action="index.php" method="post">
addcurso:<input name="nome1" type="text">
<input name="botao1" type="submit" value="Enviar" /><br />
addinstituição:<input name="nome2" type="text">
<input name="botao2" type="submit" value="Enviar" /><br />
<?php
if (!empty($_POST['nome1']))
$nome = $_POST['nome1'];
{
include "conecta_banco.inc";
$sql = "INSERT INTO cursos (cur_id, cur_name) Values ('$nome')";
$resultado = mysqli_query ($link,$sql);
echo "inserida";
mysqli_close($link);
}
?>
I believe the problem lies on that line
$sql = "INSERT INTO cursos (cur_id, cur_name) Values ('$nome')";
cur_id
is a FK ? If yes, you can remove it from that line(cur_id, cur_name)
, if not you should add something to that lineValues('$var','$nome')
– Mauro Alexandre
cur_id is auto_incremented
– Rafael
So you can remove from that line
cursos (cur_id, cur_name)
leaving onlycur_name
– Mauro Alexandre
did not solve if you have any more suggestions! I still could not solve by being beginner in programming
– Rafael
$nome = $_POST['nome1'];
before{
is not generating a fatal error? The structure of the conditional isif ( condição ) {}
. Place<?php error_reporting(E_ALL); ?>
at the beginning of the file and see if it does not give you an error message.– Ricardo Moraleida