Form to create and name new webpage from text field

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.

I can offer a few suggestions, but I would personally go at this a different way.

[php]$data[‘filename’] = $_POST[‘filename’];
$data[‘ext’] = $_POST[‘ext’];
$data[‘doctitle’] = $_POST[‘doctitle’];[/php]

For 1, this doesn’t need to be done.

For your actual issue, what happens?

Well nothing. The page with the form reloads but the new file isn’t created.
kchoopstournament.com/postattempt2.php is the link if you want to check it out to see what I’m saying.

That part seemed a little redundant but I was trying to follow his instructions as close as possible.
Could you please explain how you’d go about it if it’s not too much trouble?

Sponsor our Newsletter | Privacy Policy | Terms of Service