Live Chat using PHP and JavaScript

In this tutorial we will create a Live Chat Using PHP and jQuery. This live chat application we will be creating is a simple web-based application that creates a chat or message through the other users of this application. And it will include a login and logout system using Ajax features and it will also support for multiple users. See the example code below.

Sample Code

Index.php - For creating a login form using PHP that will ask the user their name before they continue to the chatting area.

Please enter your name to continue:

'; } if(isset($_POST['enter'])){ if($_POST['name'] != ""){ $_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name'])); } else{ echo 'Please type in a name'; } } ?>
Post.php - We have created a data that being sent to the post.php file each time the user submits the form and sends a new message. It will now create a script to get the data and display it to the chat log. (".date("g:i A").") ".$_SESSION['name'].": ".stripslashes(htmlspecialchars($text))."
"); fclose($cb); } ?>
Hope that you learn in my tutorial. Don't forget to LIKE & SHARE this website. Enjoy Coding.

Comments

Submitted bytony1122 (not verified)on Mon, 05/28/2018 - 14:27

in this code, "attr:function(J,G,K){" is no match for "}" part. and (function(){ part too. how should I put it?
Submitted byHaziq (not verified)on Sat, 08/24/2019 - 18:55

How are you message reply. Please guide me.

Add new comment