"@Fred-ii- Thank you so much that works! – Coffee coder 58 secs ago"
Use if(mysqli_affected_rows($mysqli) >0 )
or no comparison at all.
Sidenote: ==1
is only comparing for 1, as opposed to >0
which you may be trying to update more than one row. However and on the rare occasion, >0
is required where this has also happened to me before; that is the reason of my answer.
affected_rows()
uses the connection, not the one for the query.
- http://php.net/manual/en/mysqli.affected-rows.php
Plus, if you're storing plain text passwords, use password_hash()
since it's much safer:
- http://php.net/manual/en/function.password-hash.php
Sidenote: If you do decide to move over to that function, make sure that you do not manipulate the password at all. Hashing/verifying it takes care of that and you may be doing more harm than good in doing so and limiting passwords.
I.e.: A valid password of test'123
would be interpreted as test\'123
and rendering FALSE when using real_escape_string()
for example.
Or you may still be using hash_hmac
as per your other question Comparing/check if correct Password from mysqli database [hash_hmac]
and a prepared statement:
- https://en.wikipedia.org/wiki/Prepared_statement
It is also best to add exit;
after header. Otherwise, your code may want to continue to execute.
header("location: ../index.php");
exit;