Professional Documents
Culture Documents
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
XAMP Server
WAMP Server
MAMP Server
LAMP Server
Hardware Requirements:
RAM : 512 MB
Index.php:
<?php
include 'db.php';
?>
<html>
<head>
<title>chat box</title>
<script>
function ajax()
{
req.onreadystatechange=function()
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>
<?php
if(isset($_POST['submit'])){
$name=$_POST['name'];
$msg=$_POST['msg'];
$run=$con->query($query);
if($run)
?>
</div>
</body>
</html>
Style.css:
*{
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;
font-weight:bold;
}
input[type='text']{
width="100%";
height:40px;
}
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";
function formatDate($date)
include 'db.php';
$run=$con->query($query);
while($row = $run->fetch_array()) :
?>
<div id="chat_data">
<span style="color:blue;"><?php echo $row['name']; ?></span> :
</div>
By:
Panuganti varaprasad -16NN81A05M2
Sareesh goroju-16NN81A05M3