-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
64 lines (57 loc) · 1.56 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="b.css">
</head>
<body>
<h1>BRAINFLOW DISCUSSION FORUM</h1>
<div class="container" id="cont7">
<form action="" method="post">
<label for="question" class="centered">Ask a question:</label><br>
<input type="text" id="question" name="question" class="text"><br>
<input href="#msg" type="submit" class="s">
</form>
<?php
if(empty($_POST["question"]))
{
$question=null;
}
else
{
$question=$_POST["question"];
}
$date=date("Y-m-d");
$conn= new mysqli('localhost','root','','discussion_forum');
if($conn->connect_error){
die('Connection Failed :'.$conn->connect_error);
}
else{
$stmt=$conn->prepare("insert into msg(date,message)
values(?,?)");
$stmt->bind_param("ss",$date,$question);
$stmt->execute();
$stmt->close();
}
$conn= new mysqli('localhost','root','','discussion_forum');
if($conn->connect_error){
die('Connection Failed :'.$conn->connect_error);
}
else{
$query = "SELECT * FROM msg";
if ($result = $conn->query($query)) {
echo "<center><div id='forum'>";
while ($row = $result->fetch_assoc()) {
echo "<body><div id='msg'>".$row['message']."<br></div></body>";
}
echo "</div></center>";
$result->free();
}
}
?>
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
</div>
</body>