You are on page 1of 8

Online Web Chat Application

Introduction to the project:


Online chat may refers to a communication over the internet it means real-
transmission of text messages from sender to receiver

online chat may address point to point communications from one sender to
many receivers or one receiver

The purpose of this chat application is to allow users be able to the chat
with each other ,like a normal chat application. This chat application will be
written in php

Brief Overview of the technology

Front End : HTML, CSS, JavaScript, AJAX


1.HTML : HTML is used to create and save web document

2.CSS : (Cascading Style Sheet) Create attractive Layout


3.JavaScript : It is a programming language, commonly use with web
browsers
4.AJAX : It allows web pages to be updated asynchronously by exchanging
small amounts of data with the behind the scenes. It means update parts of
a web page ,without reloading the whole page

Back End: php my admin database

1.php my admin database: is used to create database


Software Requirements:(any one)

 XAMP Server
 WAMP Server
 MAMP Server
 LAMP Server

Hardware Requirements:

 Processor : Pentium – IV speed 1.8 GHZ

 Hard Disk : 80GB

 RAM : 512 MB

Index.php:

Here ,we give a all the index of a web application code

<?php

include 'db.php';

?>

<html>

<head>

<title>chat box</title>

<link rel="stylesheet" href="style.css" media="all"/ >

<script>

function ajax()
{

var req=new XMLHttpRequest();

req.onreadystatechange=function()

if(req.readyState==4 && req.status==200){

document.getElementById('chat').innerHTML=req.responseText;

req.open('GET','chat.php',true);

req.send();

setInterval(function(){ajax();},1000);

</script>

</head>

<body onload="ajax();">

<div id ="container">

<div id="chat_box">

<div id="chat">

</div>

</div>

<form method="post" action="index.php">


<input type="text" name="name" placeholder="enter name"/>

<textarea name="msg" placeholder="enter message"/></textarea>

<input type="submit" name="submit" value="sendit"/>

</form>

<?php

if(isset($_POST['submit'])){

$name=$_POST['name'];

$msg=$_POST['msg'];

$query = "INSERT INTO chat1 (name,msg) values ('$name' , '$msg')";

$run=$con->query($query);

if($run)

echo"<embed loop='false' src='chat1.wav' hidden='true' autoplay='true'/>" ;

?>

</div>

</body>

</html>
Style.css:

Here, we give a style to web page

*{

padding:0;

margin:0;

border:0;

}
body{
background:silver;
}

#container{
width:40%;

background:white;
margin:0 auto;

padding:20 px;

}
#chat_box{
width:90%;

height:400px;

#chat_data
{
width:100%;

padding:5px;

margin-bottom:5px;

border-bottom:1px solid silver;

font-weight:bold;

}
input[type='text']{
width="100%";
height:40px;

border:1px solid gray;


border-radius:5px;

}
textarea{

width="100%";

height:40px;
border:1px solid gray;
border-radius:5px;

Db.php:
Here, we give database connection

<?php
$host="localhost";
$user="root";

$pass = "";

$db_name="chat1";

$con = new mysqli($host,$user,$pass,$db_name);

function formatDate($date)

return date('g:i a', strtotime($date));


}
?>
Chat.php:

It is used to show the chat details of a user


<?php

include 'db.php';

$query="select * FROM chat1 ORDER By id DESC";

$run=$con->query($query);

while($row = $run->fetch_array()) :

?>

<div id="chat_data">
<span style="color:blue;"><?php echo $row['name']; ?></span> :

<span style="color:red ;"><?php echo $row['msg']; ?></span>


<span style="float:right;"><?php echo formatDate($row['date'])
1; ?></span>

</div>

<?php endwhile; ?>

By:
Panuganti varaprasad -16NN81A05M2
Sareesh goroju-16NN81A05M3

G Rahul Ashish Chandra-16NN81A05L9

You might also like