Внедрение шаблонизатора.
This commit is contained in:
parent
cf8f795550
commit
32ce7ad7e4
47
chat.php
47
chat.php
@ -11,13 +11,13 @@ if (empty($_SESSION['uid'])) {
|
||||
exit;
|
||||
}
|
||||
require_once "config.php";
|
||||
//include_once "functions.php";
|
||||
|
||||
$msg = $_POST['msg'] ?? null;
|
||||
$uid = $_SESSION['uid'];
|
||||
$uid = $_SESSION['uid'] ?? null;
|
||||
if ($msg) {
|
||||
try { db::c()->query('INSERT INTO `chat` (`user_id`, `msg`) VALUES (?i, "?s")', $uid, $msg); }
|
||||
catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||
try {
|
||||
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>";
|
||||
}
|
||||
}
|
||||
@ -50,24 +50,33 @@ function show_messages()
|
||||
|
||||
|
||||
show_messages();
|
||||
Template::header('chat');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<style>
|
||||
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; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<?php ?>
|
||||
<?php ?>
|
||||
</div>
|
||||
<form action="chat.php" method="post">
|
||||
<input id="msg" name="msg" size="100" placeholder="Введите сообщение...">
|
||||
<input type="submit" value="Отправить">
|
||||
</form>
|
||||
</body>
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user