Create Room When user register [SOLVED]

Results 1 to 3 of 3
  1. #1
    Apprentice animaxus is offline
    MemberRank
    Jun 2015 Join Date
    6Posts

    Create Room When user register [SOLVED]

    Hello,

    My Plan was to create a CMS that when users register, it automaticly create room with some furniture (like Official Habbo). So i searched in my RevCMS , where register query is placed.
    I got this code from class.users.php
    PHP Code:
    /*-------------------------------Adding/Updating/Deleting users-------------------------------------*/         final public function addUser($username$password$email$motto$credits$pixels$rank$figure$gender$seckey)         {                 global $engine;                                            $sessionKey 'RevCMS-'.rand(9,999).'/'.substr(sha1(time()).'/'.rand(9,9999999).'/'.rand(9,9999999).'/'.rand(9,9999999),0,33);        $engine->query("INSERT INTO users (username, password, mail, motto, credits, activity_points, rank, look, gender, seckey, ip_last, ip_reg, account_created, last_online, auth_ticket) VALUES('" $username "', '" $password "', '" $email "', '" $motto "', '" $credits "', '" $pixels "', '" $rank "', '" $figure "', '" $gender "', '" $seckey "', '" $_SERVER['HTTP_X_FORWARDED_FOR'] . "', '" $_SERVER['HTTP_X_FORWARDED_FOR'] . "', '" time() . "', '" time() . "', '" $sessionKey "')");         unset($sessionKey);                              } 
    So i added some query below the register query :
    PHP Code:
    $engine->query("INSERT INTO `rooms_data` (`roomtype`, `caption`, `owner`, `description`, `category`, `state`, `trade_state`, `users_now`, `users_max`, `model_name`, `public_ccts`, `score`, `tags`, `icon_bg`, `icon_fg`, `icon_items`, `password`, `wallpaper`, `floor`, `landscape`, `allow_pets`, `allow_pets_eat`, `allow_walkthrough`, `hidewall`, `wallthick`, `floorthick`, `achievement`, `group_id`, `game_id`, `mute_settings`, `ban_settings`, `kick_settings`, `chat_type`, `chat_balloon`, `chat_speed`, `chat_max_distance`, `chat_flood_protection`, `walls_height`) VALUES('private', '" $username "' ' Room', '" $username "', '', 1, 'open', '0', 1, 10, 'model_b', '', 0, '', 1, 0, '', '', '105', '309', '5.7', '1', '0', '0', '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, -1)");        $engine->query("INSERT INTO `items_rooms` (`user_id`,`base_item`, `extra_data`, `x`, `y`, `z`, `rot`, `wall_pos`, `rare_id`, `songcode`, `group_id`, `builders`) VALUES(2, 152, '', 3, 9, 0.000, 0, '', 0, '', 0, '0'),(2, 153, '0', 1, 10, 0.000, 2, '', 0, '', 0, '0'),(2, 4990, '', 1, 8, 0.000, 2, '', 0, '', 0, '0'),(2, 122, '', 9, 1, 1.000, 4, '', 0, '', 0, '0'),(2, 1650, '', 0, 0, 0.000, 0, ':w=6,0 l=8,29 r', 0, '', 0, '0'),(2, 2777, '', 9, 1, 0.000, 0, '', 0, '', 0, '0'),(2, 590, '', 6, 9, 0.000, 2, '', 0, '', 0, '0'),(2, 138, '', 5, 1, 0.000, 0, '', 0, '', 0, '0'),(2, 2769, '', 5, 3, 0.000, 2, '', 0, '', 0, '0'),(2, 2758, '', 6, 8, 0.000, 0, '', 0, '', 0, '0'),(2, 2788, '', 9, 4, 0.000, 0, '', 0, '', 0, '0'),(2, 4994, '', 1, 9, 0.000, 2, '', 0, '', 0, '0'),(2, 133, '', 6, 7, 0.000, 2, '', 0, '', 0, '0'),(2, 4385, '0', 1, 7, 0.000, 0, '', 0, '', 0, '0'),(2, 4385, '0', 1, 7, 1.000, 0, '', 0, '', 0, '0'),(2, 4385, '0', 2, 7, 0.000, 0, '', 0, '', 0, '0'),(2, 4385, '0', 2, 7, 1.000, 0, '', 0, '', 0, '0'),(2, 4385, '0', 3, 7, 1.000, 0, '', 0, '', 0, '0'),(2, 4385, '0', 3, 7, 0.000, 0, '', 0, '', 0, '0'),(2, 4385, '0', 5, 8, 0.000, 2, '', 0, '', 0, '0'),(2, 4385, '0', 5, 9, 0.000, 2, '', 0, '', 0, '0'),(2, 4385, '0', 5, 9, 1.000, 2, '', 0, '', 0, '0'),(2, 4385, '0', 5, 8, 1.000, 2, '', 0, '', 0, '0'),(2, 4385, '0', 5, 10, 1.000, 2, '', 0, '', 0, '0'),(2, 4385, '0', 5, 10, 0.000, 2, '', 0, '', 0, '0'),(2, 705, '0', 5, 4, 0.000, 2, '', 0, '', 0, '0'),(2, 3065, '', 5, 2, 0.000, 0, '', 0, '', 0, '0')"); 
    My Question is , when the room created, it'll automaticly create id.
    Ex. Last room id is 4, so when next create it will be 5.
    In the items_room table there is a "room_id"
    How room_id read the ID in room_data table?

    Thanks.


  2. #2
    HostSavor.com Lewislol is offline
    MemberRank
    Jul 2013 Join Date
    498Posts

    Re: Create Room When user register

    I think you could do with it with mysql_insert_id() to get the id of the previous row, if you have any questions read the PHP manual for this or feel free to ask me.
    PHP: mysql_insert_id - Manual

  3. #3
    Apprentice animaxus is offline
    MemberRank
    Jun 2015 Join Date
    6Posts

    Re: Create Room When user register

    Thanks. Problem Solved.



Advertisement