Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user = $user->find_user_by_id_oop (2);
- $user->password = "Pass";
- $user->update ();
- public function find_user_by_id_oop($user_id)
- {
- global $database;
- $result = $database->query ("SELECT * FROM users WHERE id= {$user_id} LIMIT 1");
- $found_user = $result->fetch_object ();
- return $found_user;
- }
- public function update($userID, $username, $password, $first_name, $last_name, $email)
- {
- global $database;
- global $session;
- $name = trim ($database->escape_string ($username));
- $pass = trim ($database->escape_string ($password));
- $firstname = trim ($database->escape_string ($first_name));
- $lastname = trim ($database->escape_string ($last_name));
- $email_address = trim ($database->connection->real_escape_string ($email));
- $query = "UPDATE users SET username='$name' , password='$pass' , first_name='$firstname' , last_name='$lastname' , email='$email_address' where id=$userID";
- $res = $database->query ($query);
- if ($res) {
- $session->message ('Data Updated');
- return $res;
- } else {
- $session->message ('Data Not Updated');
- }
- }
- public $username, $id, $first_name, $last_name, $password;
- $user = new User();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement