forked from hussien89aa/swa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pishing.php
79 lines (61 loc) · 2.03 KB
/
pishing.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
<?php
require("DBInfo.inc");
?>
<html lang="en" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<head>
<title>chat</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
</br>
<form id='login' action='chat.php' method='post' accept-charset='UTF-8'>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea name="chatText" class="form-control" rows="5" id="comment"></textarea>
</div>
<input type='submit' name='Submit' value='submit' class="btn btn-success" />
</form>
</br>
<div class="panel panel-primary">
<div class="panel-heading">Chat Room</div>
<div class="panel-body">
<?php
$connect = mysqli_connect($hostDB, $userDB,$passwordDB,$databaseDB);
if(mysqli_connect_errno()){
die(" cannot connect to database ". mysqli_connect_error());
}
//Insert chat text
if(!empty($_POST['chatText']) ) {
$query ="insert into chating (chatText) values ('" . $_POST['chatText'] . "')" ;
$result= mysqli_query($connect,$query);
/*if (!$result){
$output ="{ 'msg':'fail'}" ;
}else{
$output ="{ 'msg':'user is added'}" ;
}
echo $query;*/
}
//Get chat room text
$query ="select * from chating" ;
$result= mysqli_query($connect,$query);
if (!$result){
die(' Error cannot run query');
}
$userInfo=array();
echo "<ul class=\"list-group\">";
while ($row= mysqli_fetch_assoc($result)) {
echo "<li class=\"list-group-item\">" . $row["chatText"] . "</li>";
}
echo "</ul>";
mysqli_free_result($result);
mysqli_close($connect);
?>
</div>
</div>
</div>
</body>