Creating Pages in PHP

Nathan Riley
Nathan Riley used Ask the Experts™
I have a system I'm creating that takes the user to a web form they enter the information and hit submit it then inserts that data into the database.

After that I would like it to take them to the new page that is created from the web form based of a template.php file.

I have no idea where to start with this. I have the template.php file created of how it should look.

But say someone creates project 1, project 2, project 3 ect... I don't want to have to create a project1.php, project2.php, project3.php for every new project created.  Can't I somehow use a template.php file for all of them?  How will the page know if they go to http://domain/project1.php link to use the template.php file?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

insert this command where ever you want to call the template. Below, I created a template folder and place the file that I want to call on every page. It keeps it organize.

<? include("template/footer.php"); ?>
Nathan RileyFounder


I may have explained wrong:

1. So the user clicks new project, takes them to a web form to enter their title, description, ect...
2. They hit submit and the data is then inserted into the database.
3. Now I need a way to create dynamic pages, like if they create project and the id in the database is 1 then I would want the url to be for an easy example. Obviously I wouldn't want to have to create these 1.php, 2.php ect... pages for all projects. I assume it would need to use some template.php file or something when the user clicks the URL. How can I accomplish this?
Most Valuable Expert 2011
Top Expert 2016
If you're new to PHP and MySQL this book will help you get the foundation you need to do the kinds of things you're talking about here.

The creation of dynamic pages follows a fairly specific pattern.  First you examine the request data ($_GET and $_POST as well as $_SESSION and $_COOKIE, then query the data base, then build and echo the HTML string.

You probably do not want to do it the way you're describing with pages named from DB keys.  A more usual pattern is to have a single page that receives the db key in the session or in the URL, something like this:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial