Advertisement
Guest User

Untitled

a guest
Mar 27th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php
  2. require('lib/dbconnect.inc.php');
  3. require('lib/class.user.inc.php');
  4.  
  5. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
  6. $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
  7.  
  8. include('tpl/header.tpl');
  9.  
  10. switch($action) {
  11.     case 'show':
  12.         $user = User::Get($id);
  13.         include('tpl/user.show.tpl');
  14.         break;
  15.     case 'edit':
  16.         $user = User::Get($id);
  17.         include('tpl/user.edit.tpl');
  18.         break;
  19.     case 'save':
  20.         $user = $_POST;
  21.         if(SaveUser($user))
  22.             include('tpl/user.show.tpl');
  23.         else
  24.             include('tpl/error.tpl');
  25.         break;
  26.     default:
  27.         include('tpl/unknown.action.tpl');
  28.         break;
  29. }
  30.  
  31. include('tpl/footer.tpl');
  32.  
  33. /* ------------------- Save user -------------------- */
  34.  
  35. function SaveUser($user) {
  36.     global $db;
  37.  
  38.     $query = 'UPDATE users SET name="'.$user['name'].'",password="'.md5($user['password']).'",birthdate="'.$user['birthdate'].'"';
  39.     $query .= ' WHERE id='.$user['id'];
  40.    
  41.     return $db->Query($query);
  42. }
  43.  
  44. // Note: usually this function would be in
  45. //  User class (User::Save), but now its here
  46. //  so you can see what it does.
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement