bookmark - Making A Simple Webpage Generator: Part 3 Fill The Template

Making A Simple Webpage Generator: Part 3 - Fill The Template

 
 Discussion by SunBlind with 0 Replies.
 Last Update: June 29, 2005, 1:51 am
 
bookmark - Making A Simple Webpage Generator: Part 3 Fill The Template  
    
free web hosting
 
This tutorial is based on a webpage generator I made (for my users with little or no HTML knowledge) after spending about 3 months collecting javascripts, code snippets, layouts, and all that other good stuff. Since this takes quite a few steps, and I'm dead tired, I'll be posting this tutorial in 3 parts:

Part 1- Create The Template
Part 2- Make The Form
Part 3- Fill The Template

When a form using the "post" method is submitted, the values that are entered into the inputs are stored in variables. These variables are defined by the name given in the input tag of the form. But how to we get the variables to be displayed on the next page? We grab them from the form and put them in more variables! It's really not as difficult as it sounds, I just suck at explaining things... Which is why I don't even know why I'm attempting to make a tutorial, but hopefully someone will be able to decipher all of my ramblings and learn something. Anywhos, this is the final step of the tutorial: filling the template

1. Open your html template file with the pre-filled variables(you should have created this in the first part of the tutorial). Example:

CODE

<title><?php echo $title; ?></title>


2. At the very top of the page, insert the opening and closing PHP tags:

CODE

<?php

?>


3. For each webpage attribute you generated, insert the following code in between the php tags:

CODE

$variable_name = $_POST ['variable_name'];

For Example:
$bgcolor = $_POST['bgcolor'];
$header = $_POST['header'];
$news = $_POST['news'];


4. PAY CLOSE ATTENTION to the variable names. Make sure you use the same EXACT name for the variable as you did for the input. You also have to be sure that the echo tags you placed in the template in part 1 match the variable names you assigned at the top of this page. For instance, if you call for

CODE

<?php echo $txtcolor; ?>
in your template, but assigned the text color attribute to

CODE

$textcolor
It won't work!

5. Like always, make sure all of your attribute variables have been called. Save the file as "generate.php" or whatever filename you specified in form.html and upload it to your PHP enabled server. Visit http://www.yoursite.com/form.html to see your new webpage generator in action! Or you can just go see my finished product.

If you would like a textbox containing the html code you generated...

1. Place a textarea at the end of your template like so:

CODE

<textarea cols="50" rows="25"></textarea>


2. In between the textarea codes, insert the full html of your template (with the echo tags filled in).

3. That's it, Enjoy! If you have any questions, just ask or PM me :lol: I'm always happy to help.

Wed Jun 29, 2005    Reply    New Discussion   


Quickly Post to Making A Simple Webpage Generator: Part 3 Fill The Template w/o signup Share Info about Making A Simple Webpage Generator: Part 3 Fill The Template using Facebook, Twitter etc. email your friend about Making A Simple Webpage Generator: Part 3 Fill The Template Print
Reply / Comment Ask a Question? Share / Bookmark E-Mail a Friend Print

Making A Simple Webpage Generator: Part 2 The Form  Making A Simple Webpage Generator: Part 2 The Form (0) (15) CMS101 - Content Management System Design Basic CMS With PHP Includes  CMS101 - Content Management System Design Basic CMS With PHP Includes