php - comparison array doesnt work -
i have code i'm trying compare $current $password array , thought both have same value , doesn't work.
$current_password = mysqli_query($db_connection,"select password user username = 'sanket' "); $row = mysqli_fetch_array($current_password); foreach($row $pass) { $password = $pass[0]; } $current = $_post['old_password']; if ($current == $password) { if ($_post['new_password'] == $_post['confirm_password']) { mysqli_query($db_connection,"update user set password = ".$_post['confirm_password']." username = 'sanket'") ; }
$row = mysqli_fetch_array($current_password); foreach($row $pass) { $password = $pass[0]; }
$row
unidimensional array strings. when foreach on $row
$pass
string. when assign $pass[0]
$password
, assign first character of string in $pass
$password
. write:
$row = mysqli_fetch_array($current_password); $password = $row[0];
and here necessary warning: use proper escaping mysqli_prepare
or mysqli_real_escape_string
user input!
Comments
Post a Comment