DOCTYPE HTML html head meta charset windows-1251 title Чат title link

 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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="windows-1251">
<title>Чат</title>
<link rel="stylesheet" href="newcss2.css" type="text/css">
</head>
<body>
<style>
.chat{
width:90%;
height:800px;
border:1px solid black;
overflow:auto;
clear:both;
}
.textarea{
height:50px;
width:50%;
margin-top:10px;
border:1px solid black;
display:block;
}
.userName{
float:left;
display:block;
}
</style>
<div class="chat"></div>
<form action="index2.php" method="post">
<textarea class="textarea" name="textarea" placeholder ="Введите сообщение" maxlength="1000"></textarea>
<input class="userName" name="userName" type="text" placeholer="Введите имя">
<input class="submitMessage" type="submit">
</form>
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("newdatabase");
$id=0;
if (isset($_POST['textarea']) && isset($_POST['userName']))
{
$id++;
$message = $_POST['textarea'];
$today = date("Y-m-d H:i:s");
var_dump($today);
$userName = $_POST['userName'];
$user = mysql_query("SELECT * FROM `comments`");
var_dump($user);
$check = mysql_query("INSERT INTO `comments`(`id`, `author`, `date`, `comment`) VALUES ($id, $userName, $today, $message)");
var_dump($check);
echo "<script src='newJS.js'></script>";
}
?>
</body>
</html>