Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('lib/dbconnect.inc.php');
- require('lib/class.user.inc.php');
- $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
- $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
- include('tpl/header.tpl');
- switch($action) {
- case 'show':
- $user = User::Get($id);
- include('tpl/user.show.tpl');
- break;
- case 'edit':
- $user = User::Get($id);
- include('tpl/user.edit.tpl');
- break;
- case 'save':
- $user = $_POST;
- if(SaveUser($user))
- include('tpl/user.show.tpl');
- else
- include('tpl/error.tpl');
- break;
- default:
- include('tpl/unknown.action.tpl');
- break;
- }
- include('tpl/footer.tpl');
- /* ------------------- Save user -------------------- */
- function SaveUser($user) {
- global $db;
- $query = 'UPDATE users SET name="'.$user['name'].'",password="'.md5($user['password']).'",birthdate="'.$user['birthdate'].'"';
- $query .= ' WHERE id='.$user['id'];
- return $db->Query($query);
- }
- // Note: usually this function would be in
- // User class (User::Save), but now its here
- // so you can see what it does.
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement