//post.php

<?php
error_reporting(-1);

if (isset($_POST['text'])) {
	$db = array('host' => 'localhost', 'user' => 'root', 'pass' => '', 'name' => 'microboard');
	$link = mysqli_connect($db['host'], $db['user'], $db['pass'], $db['name']);

	$text = $_POST['text'];

	!empty($_POST['username']) ? $username = $_POST['username'] : $username = "Аноним";
	
	$queryResult = mysqli_query($link, "INSERT INTO `microboard`.`posts` (`name`, `message`) VALUES ('$username', '$text')");
}

header('Location: /index.php');
?>
