//index.php
<?php
require_once ( 'config.php' ) ;
$headersNumber = $queryResult -> num_rows ;
for ( $i = 0 ; $i < $headersNumber ; $i ++ ) {
}
include_once ( 'view.html' ) ;
?>
//post.php
<?php
if ( isset ( $_POST [ 'text' ] ) ) {
if ( ! empty ( $_POST [ 'username' ] ) ) { } else {
$username = "Аноним" ;
}
unset ( $_POST [ 'username' ] ) ; require_once ( 'config.php' ) ;
$queryResult = mysqli_query ( $link , "INSERT INTO `microboard`.`posts` (`name`, `message`) VALUES ('$username ', '$text ')" ) ; }
header ( 'Location: /index.php' ) ; ?>
//config.php
<?php
$db = array ( 'host' => 'localhost' , 'user' => 'root' ,
'pass' => '' ,
'name' => 'microboard' ) ;
$link = mysqli_connect ( $db [ 'host' ] , $db [ 'user' ] , $db [ 'pass' ] , $db [ 'name' ] ) ; ?>
//view.html
<!DOCTYPE html>
<html>
<head>
<title>Microboard</title>
</head>
<body>
<?php
for ( $i = 0 ; $i < $headersNumber ; $i ++ ) {
echo "<p><b>№{$posts [$i ]['id']}" ;
echo "{$posts [$i ]['name']}" ;
echo "{$posts [$i ]['posttime']}" ;
echo "</b><br>" ;
echo "{$posts [$i ]['message']}" ;
echo "</p><hr>" ;
}
?>
<form method="post" action="/post.php">
Name:
<input type="text" name="username">
<br>
Комментарий:<br>
<textarea type="text" name="text" rows="3" cols="64" required></textarea>
<br>
<input type="submit" value="Отправить пост">
</form>
</body>
</html>
Ly9pbmRleC5waHAKPD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKcmVxdWlyZV9vbmNlICgnY29uZmlnLnBocCcpOwokcXVlcnlSZXN1bHQgPSBteXNxbGlfcXVlcnkoJGxpbmssICJTRUxFQ1QgKiBGUk9NIHBvc3RzIik7CiRoZWFkZXJzTnVtYmVyID0gJHF1ZXJ5UmVzdWx0IC0+IG51bV9yb3dzOwokcG9zdHMgPSBhcnJheSgpOwoKZm9yICgkaT0wOyAkaTwkaGVhZGVyc051bWJlcjsgJGkrKykgewoJJHBvc3R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