I have an issue with my code. The purpose of the code is just a clear cut login system where you can login and create a user. My issue is with the creating a user. When I fill out the fields it'll say the error message error adding user since the user ID is zero. I asked my teacher and he said there was something wrong with my insert statements but i can't for the life of me figure it out. Can anyone point my in the right direction? Thank you! (the table name is called security)
PHP
$insert_sql ="INSERT INTO security SET ";
$insert_sql .= " username = '".$username ."'";
$insert_sql .= ", first_name = '".$first_name."'";
$insert_sql .= ", last_name = '".$last_name."'";
$insert_sql .= ", email = '".$email."'";
$insert_sql .= ", password = '". $salted_password . "'";
$result = $dbh->query($insert_sql);
$user_id = $dbh->insert_id;
if ($user_id > 0){
session_start();
$_SESSION['user_id'] =$user_id;
echo "Login Created and user logged in<p>";
echo "<a href=main.php>Click here to continue</a><p>";
} else {
$msg = 'Error adding user';
NEW_LOGIN($dbh,$msg);
}
}
}