Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. $user = $user->find_user_by_id_oop (2);
  2. $user->password = "Pass";
  3. $user->update ();
  4.  
  5. public function find_user_by_id_oop($user_id)
  6. {
  7. global $database;
  8. $result = $database->query ("SELECT * FROM users WHERE id= {$user_id} LIMIT 1");
  9. $found_user = $result->fetch_object ();
  10.  
  11. return $found_user;
  12. }
  13.  
  14. public function update($userID, $username, $password, $first_name, $last_name, $email)
  15. {
  16. global $database;
  17. global $session;
  18. $name = trim ($database->escape_string ($username));
  19. $pass = trim ($database->escape_string ($password));
  20. $firstname = trim ($database->escape_string ($first_name));
  21. $lastname = trim ($database->escape_string ($last_name));
  22. $email_address = trim ($database->connection->real_escape_string ($email));
  23.  
  24. $query = "UPDATE users SET username='$name' , password='$pass' , first_name='$firstname' , last_name='$lastname' , email='$email_address' where id=$userID";
  25. $res = $database->query ($query);
  26.  
  27.  
  28. if ($res) {
  29.  
  30. $session->message ('Data Updated');
  31. return $res;
  32.  
  33. } else {
  34.  
  35. $session->message ('Data Not Updated');
  36.  
  37. }
  38.  
  39. }
  40.  
  41. public $username, $id, $first_name, $last_name, $password;
  42.  
  43. $user = new User();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement