-
Notifications
You must be signed in to change notification settings - Fork 32
/
chatinsert.php
82 lines (66 loc) · 1.37 KB
/
chatinsert.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!--
<form action="adchat.php" method="POST">
Name<input type="text" name="username" value="admin" readonly ><br>
message<input type="text" name="msg"><br>
<input type="submit" value="send">
</form>
-->
<style>
.chatmsg
{
background-color: blue;
border: 1px solid blue;
border-radius: 10px;
height:50px;
width:80px;
padding: 8px;
color: white;
}
.adchatmsg
{
background-color: green;
border: 1px solid green;
border-radius: 10px;
height:50px;
width:80px;
padding: 8px;
color: white;
}
</style>
<?php
session_start();
?>
<!--to send message-->
<?php
if(isset($_POST['username']))
{
$message=$_POST["msg"];
$username=$_SESSION["username"];
//$gen=$_POST["gender"];
if($message=="" )
{
echo "all inputs required";
}
else
{
if($_SERVER['REQUEST_METHOD']=="POST")//con establish
{
$localhost = "localhost";
$usernamew = "root";
$passwordw = "";
$db = "expdb";
$conn = mysqli_connect($localhost,$usernamew,$passwordw,$db);
if(!$conn){
echo "";
}
else
{
echo "";
}
$time= date("m/d/y G.i:s<br>", time());
$sql = "insert into chattable values('$username','$message','$time')";
$result = mysqli_query($conn,$sql);
// echo "message sent!";
header('Location: chat2.php');
}}}
?>