Ive set up AJAX Chat blueimp.net/ajax/ And im trying to interegate the users from a pre existing online games website so they can log in with their credentials into AJAX Chat. The default users are put in a users.php (in the code below) <?php /* * @package AJAX_Chat * @author Sebastian Tschan * @copyright (c) Sebastian Tschan * @license GNU Affero General Public License * @link blueimp.net/ajax/ */ // List containing the registered chat users: $users = array(); // Default guest user (don't delete this one): $users[0] = array(); $users[0]['userRole'] = AJAX_CHAT_GUEST; $users[0]['userName'] = null; $users[0]['password'] = null; $users[0]['channels'] = array(0); // Sample admin user: $users[1] = array(); $users[1]['userRole'] = AJAX_CHAT_ADMIN; $users[1]['userName'] = 'admin'; $users[1]['password'] = 'admin'; $users[1]['channels'] = array(0,1); // Sample moderator user: $users[2] = array(); $users[2]['userRole'] = AJAX_CHAT_MODERATOR; $users[2]['userName'] = 'moderator'; $users[2]['password'] = 'mod'; $users[2]['channels'] = array(0,1); // Sample registered user: $users[3] = array(); $users[3]['userRole'] = AJAX_CHAT_USER; $users[3]['userName'] = 'user'; $users[3]['password'] = 'u'; $users[3]['channels'] = array(0,1); ?> Code (markup): But i want to make it so it reads the username from a mysql database "ava_users --> username" and the password "ava_users --> password). Start of the MYSQL config.php - ive set up all the values but taken them out since its posted online. <?php /* * @package AJAX_Chat * @author Sebastian Tschan * @copyright (c) Sebastian Tschan * @license GNU Affero General Public License * @link blueimp.net/ajax/ */ // Define AJAX Chat user roles: define('AJAX_CHAT_CHATBOT', 4); define('AJAX_CHAT_ADMIN', 3); define('AJAX_CHAT_MODERATOR', 2); define('AJAX_CHAT_USER', 1); define('AJAX_CHAT_GUEST', 0); // AJAX Chat config parameters: $config = array(); // Database connection values: $config['dbConnection'] = array(); // Database hostname: $config['dbConnection']['host'] = 'host'; // Database username: $config['dbConnection']['user'] = 'user'; // Database password: $config['dbConnection']['pass'] = 'pass'; // Database name: $config['dbConnection']['name'] = 'name'; // Database type: $config['dbConnection']['type'] = 'type'; // Database link: $config['dbConnection']['link'] = null; Code (markup): Can anyone help me to make it read from the database, Thanks. note: it uses mysql to log what ips are logged onto chat.
Add a role field to your existing users table in the database Then fetch the user details from there and put in this variable