<?php
$tpl_file = "page.html";
//path to the directory at the server, where you store the "page.html" file.
$tpl_path = "page/sidor";
//path to the directory where you will store the new page.
$post_path = "page/";
$data['title'] = "HopeForIt";
$data['imgSrc'] = "hello.jpg";
$data['uploadedBy'] = "Archiie";
$data['category'] = "Hope";
$data['bildId'] = "BildId3";
$placeholders = array("{title}","{imgSrc}", "{uploadedBy}", "{category}", "{bildId}");
$tpl = file_get_contents($tpl_path.$tpl_file);
$new_post_file = str_replace($placeholders, $data, $tpl);
$html_file_name = $data['title'].".html";
?>
<html>
<head>
<title>Spara filen på en sida.</title>
</head>
<body>
<?php
echo "1: ".$data['title']."<br>, 2: ".$data['imgSrc']."<br/>, 3: ".$data['uploadedBy']."<br/>, 4: ".$data['category']."<br/>, 5: ".$data['bildId'];
$fp = fopen($post_path.$html_file_name, "w");
fwrite($fp, $new_post_file);
fclose($fp);
?>
</body>
</html>