
|
View Full Version : automatic page generation
ethereality 08-11-2005, 09:01 PM I was wondering if there is any easy way to make a page out of what is posted in a form.
Such as:
User submits this form:
Name:
Header Text:
Footer Text:
And it would create a file, and insert the $name, $header, $footer variables in the newly created file.
Also, is there a way to insert a line while it's inserting $name, $header, $footer without the user inputting it?
Graeme_H 08-12-2005, 12:05 AM Yes, it would be very easy to do with php. There's some basic php tutorials here that should help you: w3schools.com/php/default.asp
ethereality 08-12-2005, 02:15 PM Thank you for the useful information, unfortunately, I still don't understand how to do what I need to do.
ethereality 08-14-2005, 12:24 AM okay.. this should better describe what I want:
Some type of forum that consists of 3 input areas:
Page Name, Board, Table, and Header Text
This is the basic file I would like to create upon submitting the information (the title of the page would be the data submitted into "page name"):
<?php
$title = "(contents from "board")";
$table = "(contents from "table")";
$header = "(content from "header text")";
echo("$header");
include("board_code.php");
?>
Is there any way to do that?
hiryuu 08-14-2005, 01:38 AM Perhaps you want a template system, which would let you plug values into a basic layout. You can echo or save the resulting page.
ethereality 08-14-2005, 03:09 PM I don't quite understand... I know there is a way to do this, I've seen it done before.
Is the "template system" you're talking about a way of creating pages?
Mindless_Spider 08-14-2005, 09:38 PM ok, i dont really have time to look up the sites that would tell you how to do this, id check php.net first tho, your going to want to look up file creation methods, and get the command for making a text file and having the script save it as a php extension, i know it can be done, i saw how to do it once while finding out how to have a script make folders.
then you'll want to specify what goes into this file.
$header = $_POST[header];
$title = $_POST[title];
$table = $_POST[table];
$board_rules = 'whatever your board rules are';
/****begin file creation****\
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php
echo $header;
echo $board_rules;
?>
</body>
</html>
/****end file creation****\
hope this helps a little
-Mindless_Spider-
hehachris 08-15-2005, 01:44 PM i hope i understand wt u meant
actually its quite easy
sample: http://knetgb.com/123.php
hope this helps =]
<?php
if(!$_POST['submit']){//display the form before submit
?>
<form method=post action=<?=$PHP_SELF?>>
Name: <input type=text name=name><br>
Header: <input type=text name=header><br>
Footer: <input type=text name=footer><br>
<input type=submit name=submit>
</form>
<?
} else{
?>
Name: <?=$_POST['name']?><br>
Header: <?=$_POST['header']?><br>
Footer: <?=$_POST['footer']?>
<?
}
?>
ethereality 08-15-2005, 08:38 PM Hi, thank you both. I'm not sure hehachris' method is the one I want.
I tried searching php, but found nothing. I really don't know what to search for... I tried creation, page creation, creating pages.. the only thing I didn't try was page for obvious reasons.
azizny 08-16-2005, 01:13 AM $file = fopen("pagename.html",'w');
fwrite($file,$HTML_STUFF);
fclose($file);
where $HTML_STUFF contains all your html data..
Peace,
ethereality 08-16-2005, 11:27 PM Okay, that seems good. Not what I wanted, but hopefully I can implement it.
But, I have another question...
Is it possible to change variables according to if statements.. such as:
if ($opt == main_board){
$header = "<html>stuff here";
$footer = "</html>";
$table = "mysql_table";
};
Also.. if that is possible how would I have it instert into the file on the top, instead of adding it to the bottom?
hehachris 08-17-2005, 02:39 AM it is possible, but better add an else{} and define the value of those varibles when the condition is not in "$opt == main_board"
u should insert these lines before the line u call/use the varibles, unlinke function =]
|