View file newc.php

File size: 0.98Kb
<?php
include 'inc/db.php';
include 'inc/1.php';
if (!$user)header("Location: /aut.php");
if (($user['admin']==0) && ($user['moder']==0)){header("Location: /chat.php");
exit;}
echo "<div class='input'>Новый чат</div>";
//начало
if (!$_POST['OK']){
echo "<div class='input'><form action='newc.php' method='POST'>Имя:<br><input type='text' name='name'><br><input type='submit' name='OK' value='Создать'></form></div>";
include_once 'inc/foot.php';
exit;
}
if (!$_POST['name']){
echo "<div class='msg'>Не заполнено поле имени!</div>";
include_once 'inc/foot.php';
exit;
}
$name=mysql_escape_string($_POST['name']);
$msg=mysql_escape_string($_POST['msg']);
mysql_query("INSERT INTO `room` (`name`) values ('$name')");
echo "<div class='msg'>Создано!</div>";
mysql_query("INSERT INTO `log` (`user`, `text`, `time`) values ('$user[id]', 'Комната в чате', '".time()."')");
//конец
include_once 'inc/foot.php';
?>