This is very risky coding. What if someone (traditionally referred to as Little Bobby Tables) changed his password to
hello';--
and your query became
UPDATE users SET Password='hello';-- ' WHERE Username='$_POST[username]'";
which -- being a comment, gets interpreted as a very broad
UPDATE users SET Password='hello';
Your error now was that you forgot the quotes around the password -- but what you should do is move to PDO. Then your query might become
$stmt = $dbh->prepare('UPDATE users SET Password=? WHERE Username=?');
$stmt->execute($pass_word, $_POST['username']);
with the PDO layer taking care of avoiding troubles.
The same thing applies to $_POST[username]
, and I suggest you write it as "{$_POST['username']}" - it's more easily parsed by several PHP tools, and allows you more flexibility with complex arrays.