This question already has an answer here:
I don't know what is wrong with this code. The data isn't inserting into the database.
$connection = mysqli_connect('localhost', 'root', '', 'login-system');
if ($connection) {
echo "everything works fine";
} else {
echo "there is something wrong";
}
if (isset($POST['submit'])) {
$username = $POST['username'];
$password = $POST['password'];
$query = "INSERT INTO users(username, password)";
$query .= 'VALUES("$username", "$password")';
$result = mysqli_query($connection,$query);
if (!$result) {
die('Query Failed'. mysqli_error());
}
}
Do you have any suggestion why this not working. Remember the server gets connected to database but not inserting data.
Thanks
</div>