| You are here: DEVPPL ‹ Forum ‹ Programming ‹ PHP and MySQL Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
Using a PHP form to create a static HTML page
3 posts
• Page 1 of 1
0
Using a PHP form to create a static HTML page
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
0
I haven't tested this script yet, but it should work:
And welcome to DEVPPL rse.
- 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]!
[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
|
|