Внедрение шаблонизатора.
This commit is contained in:
parent
cf8f795550
commit
32ce7ad7e4
47
chat.php
47
chat.php
@ -11,13 +11,13 @@ if (empty($_SESSION['uid'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
//include_once "functions.php";
|
|
||||||
|
|
||||||
$msg = $_POST['msg'] ?? null;
|
$msg = $_POST['msg'] ?? null;
|
||||||
$uid = $_SESSION['uid'];
|
$uid = $_SESSION['uid'] ?? null;
|
||||||
if ($msg) {
|
if ($msg) {
|
||||||
try { db::c()->query('INSERT INTO `chat` (`user_id`, `msg`) VALUES (?i, "?s")', $uid, $msg); }
|
try {
|
||||||
catch (\Krugozor\Database\Mysql\Exception $e) {
|
db::c()->query('INSERT INTO `chat` (`user_id`, `msg`) VALUES (?i, "?s")', $uid, $msg);
|
||||||
|
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||||
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
|
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,24 +50,33 @@ function show_messages()
|
|||||||
|
|
||||||
|
|
||||||
show_messages();
|
show_messages();
|
||||||
|
Template::header('chat');
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<style>
|
||||||
<html>
|
form {
|
||||||
<head>
|
padding: 3px;
|
||||||
<meta charset="utf-8">
|
position: fixed;
|
||||||
<link rel="stylesheet" href="css/main.css">
|
bottom: 0;
|
||||||
<style>
|
width: 100%;
|
||||||
form { padding: 3px; position: fixed; bottom: 0; width: 100%; }
|
}
|
||||||
form input { border: 0; padding: 10px; width: 80%; margin-right: .5%; }
|
|
||||||
form input[type="submit"] { width: 15%; border: none; padding: 10px; }
|
form input {
|
||||||
</style>
|
border: 0;
|
||||||
</head>
|
padding: 10px;
|
||||||
<body>
|
width: 80%;
|
||||||
|
margin-right: .5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
form input[type="submit"] {
|
||||||
|
width: 15%;
|
||||||
|
border: none;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div>
|
<div>
|
||||||
<?php ?>
|
<?php ?>
|
||||||
</div>
|
</div>
|
||||||
<form action="chat.php" method="post">
|
<form action="chat.php" method="post">
|
||||||
<input id="msg" name="msg" size="100" placeholder="Введите сообщение...">
|
<input id="msg" name="msg" size="100" placeholder="Введите сообщение...">
|
||||||
<input type="submit" value="Отправить">
|
<input type="submit" value="Отправить">
|
||||||
</form>
|
</form>
|
||||||
</body>
|
|
Loading…
Reference in New Issue
Block a user