ilayaraja Posted October 11, 2011 Share Posted October 11, 2011 Hi, I need to develop a module called chat with doctor. User can able to chat with the doctor for that he has to pay some amount to website. Say example user got purchase the Package worth : 2$ =>5min. After 5 min chat will be closed , timer should be shown while chatting. How can we do this? Quote Link to comment https://forums.phpfreaks.com/topic/248888-need-php-chat-application-help/ Share on other sites More sharing options...
WebStyles Posted October 11, 2011 Share Posted October 11, 2011 since you'll probably be using ajax to update the chat window, also use javascript to update the timer. Quote Link to comment https://forums.phpfreaks.com/topic/248888-need-php-chat-application-help/#findComment-1278138 Share on other sites More sharing options...
codefossa Posted October 11, 2011 Share Posted October 11, 2011 A simple way would have a chat input form and a div. When you submit form, have the default action cancelled and use AJAX to submit to the PHP page that processes the messages and stores them in the database. The database should hold the information on how long you can chat, or more precisely the time in which your chat should end. Use Javascript to show the countdown timer on the chat page, and just load the end time from the database into a session variable so you don't have to query it every time. Also, you could just insert the start/end time and by the insert query, you would have the end time to store in the session. The payments would be set up separately and just put it in the user table how much time or credits (whatever you want), that they have and take away as much as necessary when they chat. You would probably want a failsafe to save their time if they quit the chat early so they don't spend money and because of a number of reasons, they could lose their page and with that, the chat. You could do that completely in PHP on the chat page mentioned earlier, and you could use Javascript/AJAX to give a few more options like manually stopping the convo and saving your time left, and a number of other things. Chats are easy, but make sure you don't screw up the time/money usage or you will have some angry customers. Quote Link to comment https://forums.phpfreaks.com/topic/248888-need-php-chat-application-help/#findComment-1278428 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.