I have created template for user to user chat module. Need help to complete realtime chat.
Need some validations like highlight chat window on message received if it is inactive.
to_id
is collected in script (var userid
). how to collect from_id
, if user is logged in via php. currently there is no login, but i will add login script later.
How to get session id or login id in javascript
Template
https://jsfiddle.net/oxch99us/
Database
CREATE TABLE `chat_interactions` (
`message_id` bigint(11) NOT NULL,
`to_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`from_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`message` text COLLATE utf8_unicode_ci NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`ip_address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `chat_interactions`
ADD PRIMARY KEY (`message_id`);
ALTER TABLE `chat_interactions`
MODIFY `message_id` bigint(11) NOT NULL AUTO_INCREMENT;