I am trying to insert some data into my database with this code:
$username = $_SESSION['user'];
$naslov = $_POST['naslov'];//name
$geslo = $_POST['geslo'];//password
$vsebina = $_POST['vsebina'];//description
if (trim($_POST['naslov'])=="" || $_POST['geslo']=="" || $_POST['vsebina']==""){
$status = "<div class='alert-danger'>Fields are empty</div>";
}
else{
$link = open_database_connection();
echo $username;
echo $naslov;
echo $geslo;
echo $vsebina;
$sql = "INSERT INTO projects (name, password, description, username) VALUES ('$naslov','$geslo','$vsebina','$username')";
mysqli_query($link, $sql);
close_database_connection($link);
$status = "<div class='alert-success'>Vic je bil dodan.</div>";
}
The echo show the values i am putting into the forms, the SQL does not show any errors it just doesn't insert the values into the table.
close_database_connectioninstead ofmysqli_close($link), is there maybe more fancy stuff that can break the code. What doesopen_database_connection()really do? Did theopen_database_connection()also select the right Database?