I’m trying to make a php page that has a text field where any user can input something like “example.php” and click submit and have it create that page based off a template I already have. I also need the form to have 1 more additional variable in the form of another text field that replaces the text in the tag of the new page. can anyone please help me out?
Oh and here is the forum post i’ve been trying to follow but I got lost somewhere around posting the form and saving it as an array. ???:
http://www.webmasterworld.com/php/3552317.htm
here is my code:
Code: [Select]
<?php
$tpl_file = "template.php";
$tpl_path = "/";
$members_path = "/";
$data['filename'] = $_POST['filename'];
$data['ext'] = $_POST['ext'];
$data['doctitle'] = $_POST['doctitle'];
$placeholders = array("{filename}", "{ext}", "{doctitle}");
$tpl = file_get_contents($tpl_path.$tpl_file);
$new_member_file = str_replace($placeholders, $data, $tpl);
$html_file_name = $data['filename'].$data['ext'];
$fp = fopen($members_path.$html_file_name, "a");
fwrite($fp, $new_member_file);
fclose($fp);
?>
Heres the form: [code]
File Name:
.html
.php
.js
.css
Page Title:
<label for="doctitle"></label>
<input name="doctitle" type="text" id="doctitle" size="40" />
</p></td>
<td width="223" align="center">
<input type="submit" name="createpage" id="createpage" value="Create New Webpage" />
</form>[/code]
thanks in advance I’m a total newb at php so please take it easy.