- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
if(!empty($_POST))
{
	include("dbconnect.php");
	$shown_name=$_POST['shown_name'];
	$username=$_POST['username'];
	$header=$_POST['header'];
	$text=$_POST['text'];
	$date_array=getdate(time());
	$date=$date_array['hours'].":".$date_array['minutes'].":".$date_array['seconds']." ".$date_array['weekday']." ".$date_array['mday']." ".$date_array['month']." ".$date_array['year'];
	$filename=$date_array['hours']."-".$date_array['minutes']."-".$date_array['seconds']."-".$date_array['mday'].$date_array['month']."-".$date_array['year']."-".$username.".php";
	$path="posts/".$filename;
	$addpost="INSERT INTO posts(author, header, text, date, path) VALUES ('$shown_name', '$header', '$text', '$date', '$path')";
	$add=$db->prepare($addpost);
	$add->execute();
	$file=fopen($path, 'w');
	$content="<?php \$shown_name=\"".$shown_name."\"; \$header=\"".$header."\"; \$text=\"".$text."\";  include(\"template.html\"); ?>";
	$write=fwrite($file, $content);
	fclose($file);
	header('Location: index.php');
	$db=null;
}
                                     
        
            Добавление поста в блог. Радует каждая строчка.