Created
September 3, 2012 21:42
-
-
Save psykzz/3613795 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateUser ($userID,$userData) { | |
$salt = $this::MD5_SALT; | |
if ($userData['password']=!"") { | |
$password = md5("{$salt}:{$userData['password']}"); | |
$SQL = | |
"UPDATE `tblUsers` | |
SET `username`=?, `password`=?, `group`=? `access`=? | |
WHERE `user_id`=?;"; | |
} else { | |
$SQL = | |
"UPDATE `tblUsers` | |
SET `username`=?, `group`=? `access`=? | |
WHERE `user_id`=?;"; | |
} | |
if ($this->stmt = mysqli_prepare($this->link, $SQL)) { | |
if ($userData['password']=!"") | |
mysqli_stmt_bind_param($this->stmt, "ssi", $userData['username'], $userData['group'], $userData['access']); | |
else | |
mysqli_stmt_bind_param($this->stmt, "sssi", $userData['username'], $password, $userData['group'], $userData['access']); | |
mysqli_stmt_execute($this->stmt); | |
$assert = mysqli_stmt_affected_rows($this->stmt); | |
mysqli_stmt_close($this->stmt); | |
} else { | |
throw new Exception("Error preparing results",$this::MYSQLI_ERROR); | |
} | |
if ($assert>0) | |
return true; | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment