You are here: DEVPPL Forum Programming PHP and MySQL Forum
NOTIFICATIONS
54.094
MEMBERS
15.692
TOPICS
62.270
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

Using a PHP form to create a static HTML page

0

Loading

Using a PHP form to create a static HTML page

Postby Rse » Sun Oct 10, 2004 9:28 pm

:?:

Help! What i'm wanting to do is create a simple form where users type in the title, content and filename of the page they want to create, then when they press submit PHP automagically creates a file with the content saved within.

I.E, the user types the title "Test", the content "Test Content" and the filename test.php then submits the form. PHP then generates a page using a template perhaps which is called "test.php" which contains the title and content as submitted in the form.

Any ideas?

Ads
Rse
 
Reputation: 0
Posts: 141
Joined: Sun Oct 10, 2004 9:15 pm
Location: Leeds, UK
Highscores: 0
Arcade winning challenges: 0

Using a PHP form to create a static HTML page - Sponsored results

Sponsored results

Login to get rid of ads

 

0

Loading

Postby Rasmus Lindström » Sun Oct 10, 2004 11:08 pm

I haven't tested this script yet, but it should work:

Code: Select all
<?

if(isset($_POST['B1'])) {

   $sitename = $_POST['sitename'];
   $title = $_POST['title'];
   
   $entry_line = "<html><head><title>$title</title></head><body>This is a text generated by DEVPPL</body></html>";
   $fp = fopen("$sitename.htm", "a");
   fputs($fp, $entry_line);
   fclose($fp);

   echo "<a href='$sitename.htm'>CLICK HERE TO VISIT YOUR SITE<p/></a>";
}
?>

<form method='POST' action='<? $PHP_SELF ?>'>
The name of your site: (eg index)<br/>
<input type='sitename' name='sitename'>.htm
<p/>
Title you wish to use: (max 255 chars)<br/>
<input type='title' name='title'>
<p/>
<input type='submit' name='B1' value='generate my page'>
</form>


And welcome to DEVPPL rse.
[url=http://www.linkedin.com/profile/view?id=96243938]Meet me on LinkedIn[/url]
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2830
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Postby Rse » Mon Oct 11, 2004 6:18 am

Thanks, works perfectly! I thought it would need to use fopen, i just couldn't get my head around it.

Hopefully i can help someone else out next time :D

Thanks webmaster!
Rse
 
Reputation: 0
Posts: 141
Joined: Sun Oct 10, 2004 9:15 pm
Location: Leeds, UK
Highscores: 0
Arcade winning challenges: 0
^ Back to Top