I'm trying to send a simple title to my database, but for some reason it keeps giving me this error:
> Error: INSERT INTO `formular` (`idFormular`, `idUser`, `Nume`) VALUES (NULL, 'qwe', 'Test1');
Column 'idformular' cannot be null
I've tried to change the insert function many times but nothing worked. This is the code I'm using:
<?php
session_start();
include 'connections.php';
$name = $_POST['nume'];
$id = $_SESSION['username'];
$name = stripcslashes($name);
$name = mysqli_real_escape_string($con, $name);
$sql = "INSERT INTO `formular` (`idFormular`, `idUser`, `Nume`) VALUES (NULL, '$id', '$name');";
if ($con->query($sql) === true) {
$sql1 = "SELECT idFormular FROM `formular` WHERE idUser=$id AND Nume='$name';";
$result = mysqli_query($con, $sql1);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$idForm = $row["idFormular"];
$_SESSION["idForm"] = $idForm;
header("Location:Forms.php", true, 301);
exit();
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
$con->close();