mysql - PHP function (adding records) not working correct -
i working on website have user adding form. following function addrecord(). when admin user creating new user, function adds rows in sql table. but, every time add new users, stucked @ error message "user name/password not added contact", @ first else statement. when check table, access level , password fields having data, cannot log in hashed password. help, what's wrong code?
thanks, sixxdog
public function addrecord() { // verify fields if ($this->_verifyinput()) { // prepare encrypted password $password = trim($_post['password1']); // database connection $connection = database::getconnection(); // prepare data $query = "insert contacts(first_name, last_name, position, email, phone) values ('" . database::prep($this->first_name) . "', '" . database::prep($this->last_name) . "', '" . database::prep($this->position) . "', '" . database::prep($this->email) . "', '" . database::prep($this->phone) . "')"; // run mysql statement if ($connection->query($query)) { // inserts row // update user name , password know id $query = "update contacts set user_name = '" . database::prep($this->user_name) . "', password = '" . hash_hmac('sha512', $password . '!hi#hude9' . mysql_insert_id(), site_key) ."', access = '" . database::prep($this->access) . "'"; if ($connection->query($query)) { // updates row $return = array('', 'contact record added.', ''); // add success message return $return; } else { // send fail message $return = array('', 'user name/password not added contact.', ''); return $return; } } else { // send fail message , return contactmaint $return = array('contactmaint', 'no contact record added. unable create record.', '0'); return $return; } } else { // send fail message , return contactmaint $return = array('contactmaint', 'no contact record added. missing required information or problem user name or password.', '0'); return $return; } }
there's no where
clause in update statement. perhaps user_name
column has unique index on it?
Comments
Post a Comment