-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchat.php
More file actions
36 lines (27 loc) · 722 Bytes
/
chat.php
File metadata and controls
36 lines (27 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$dbHost = "localhost";
$dbUsername = "krutika";
$dbPassword = "krutika123";
$dbName = "mydb";
// Create database connection
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
// Check connection
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
$q1='INSERT INTO 'message'('id','message','user_name')
VALUES("","'.$message.'","'.$_SESSION['user_name'].'")';
$r1=mysqli_query($con.$q1);
while($row=mysqli_fetch_assoc($r)){
$message=$row['message'];
$user_name=$row['|']
}
if (isset($_POST['send'])){
$message=$_POST['message'];
}
if(mysqli_query($con,$q)){
echo'<h4 style="color:red">'.$_SESSION['user_name'].'</h4>';
echo'<p>'.$message.'</p>';
}
}
>