<head>
<meta charset="UTF-8">
<title></title>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<?php
$pdo = new PDO( 'mysql:host=localhost;dbname=chat;charset=utf8' , 'root' , '' ) ;
?>
<script type="text/javascript">
//Загружаем библиотеку JQuery
//Функция отправки сообщения
function send()
{
//Считываем сообщение из поля ввода с id mess_to_add
var mess=$("#mess_to_send").val();
// Отсылаем паметры
$.ajax({
type: "POST",
url: "index.php",
dataType: "html", //Тип данных
data:"mess="+mess,
// Выводим то что вернул PHP
success: function(html)
{
//Если все успешно, загружаем сообщения
load_messes();
//Очищаем форму ввода сообщения
$("#mess_to_send").val('');
}
});
}
//Функция загрузки сообщений
function load_messes()
{
$.ajax({
type: "POST",
url: "load_messes.php",
data: "req = ok",
// Выводим то что вернул PHP
success: function(html)
{
//Очищаем форму ввода
$("#messages").empty();
//Выводим что вернул нам php
$("#messages").append(html);
//Прокручиваем блок вниз(если сообщений много)
$("#messages").scrollTop(90000);
}
});
}
</script>
<?php
if ( isset ( $_POST [ 'mess' ] ) && $_POST [ 'mess' ] != "" && $_POST [ 'mess' ] != " " ) {
$mess = $_POST [ 'mess' ] ;
$login = $_SESSION [ 'login' ] ;
include ( "config.php" ) ;
$stmt = $pdo -> prepare ( "INSERT INTO messages (login, message) VALUES ($login , $mess )" ) ;
$stmt -> bindValue ( ':user' , $user , PDO:: PARAM_STR ) ;
$stmt -> execute ( ) ;
}
?>
<table>
<tr>
<td>
<div id="messages">
</div>
</td>
</tr>
<tr>
<td>
<form action="javascript:send()" method="post" id="form_id">
<textarea id="mess_to_send"></textarea>
<button type="submit">Send</button>
</form>
</td>
</tr>
</table>
ICAgIDxoZWFkPgogICAgICAgIDxtZXRhIGNoYXJzZXQ9IlVURi04Ij4KICAgICAgICA8dGl0bGU+PC90aXRsZT4KICAgICAgPHNjcmlwdCBzcmM9Ii8vY29kZS5qcXVlcnkuY29tL2pxdWVyeS0xL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MiKS5zY3JvbGxUb3AoOTAwMDApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICB9CiAgICAgICAgfSk7Cgl9CiAgICAgICAKPC9zY3JpcHQ+Cjw/cGhwCmlmKGlzc2V0KCRfUE9TVFsnbWVzcyddKSAmJiAkX1BPU1RbJ21lc3MnXSE9IiIgJiYgJF9QT1NUWydtZXNzJ10hPSIgIikKewoJCglzZXNzaW9uX3N0YXJ0KCk7CgkKCSRtZXNzPSRfUE9TVFsnbWVzcyddOwoJCgkkbG9naW49JF9TRVNTSU9OWydsb2dpbiddOwoJCglpbmNsdWRlKCJjb25maWcucGhwIik7CgkKCiAgICAgICAgCiAgICAgICAgCiAgICAgICAgICAgJHN0bXQgPSAkcGRvLT5wcmVwYXJlKCJJTlNFUlQgSU5UTyBtZXNzYWdlcyAobG9naW4sIG1lc3NhZ2UpIFZBTFVFUyAoJGxvZ2luLCAkbWVzcykiKTsKJHN0bXQtPmJpbmRWYWx1ZSgnOnVzZXInLCAkdXNlciwgUERPOjpQQVJBTV9TVFIpOwokc3RtdC0+ZXhlY3V0ZSgpOwp2YXJfZHVtcCgkbWVzcyk7Cn0KPz4KCgo8dGFibGU+Cjx0cj4KPHRkPgo8ZGl2IGlkPSJtZXNzYWdlcyI+CjwvZGl2Pgo8L3RkPgo8L3RyPgo8dHI+Cjx0ZD4KPGZvcm0gYWN0aW9uPSJqYXZhc2NyaXB0OnNlbmQoKSIgbWV0aG9kPSJwb3N0IiBpZD0iZm9ybV9pZCI+CiAgICA8dGV4dGFyZWEgIGlkPSJtZXNzX3RvX3NlbmQiPjwvdGV4dGFyZWE+CjxidXR0b24gdHlwZT0ic3VibWl0Ij5TZW5kPC9idXR0b24+CjwvZm9ybT4KPC90ZD4KPC90cj4KPC90YWJsZT4KCgoK
stdout
<head>
<meta charset="UTF-8">
<title></title>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
stderr
PHP Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /home/IFmC6m/prog.php:10
Stack trace:
#0 /home/IFmC6m/prog.php(10): PDO->__construct('mysql:host=loca...', 'root', '')
#1 {main}
thrown in /home/IFmC6m/prog.php on line 10