Use a Template to Create New URLs/ Content from MySQL?

Hi Expert,

What I would like to do is use a form that the user purs information in to create pages. So I would have one page, that will have CSS and basically look like a template, then it will grab data from a database to display content like the title, description (of the page in body), and pictures or videos. It will then have a unique 6 letter generated URL for each page like "website.com/page/bsdccz-Title of My Page"
Andy_FangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Yes, that is entirely feasible.  What is the question?
0
Andy_FangAuthor Commented:
How do I create songthing like this? I'm not sure how I would use a single template to create many different pages that are generated by a user with a form.
0
Ray PaseurCommented:
This is such a broad question that it is impossible to give a useful answer.  It's like saying, "I want to build a car."  There are a lot of good learning resources identified in this article.  Please start there, and get a foundation in how PHP can be used to generate HTML documents.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

While you're reading that, I will try to show you a basic templating engine that will take client input and use it in a generated HTML document.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Use "view source" to look at the generated HTML.
http://www.laprbass.com/RAY_temp_andy_fang.php

<?php // RAY_temp_andy_fang.php
error_reporting(E_ALL);

// SEE http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28228871.html

// IF THERE IS A REQUEST FROM THE CLIENT
if (!empty($_POST['data']))
{
    /* USING THE CLIENT INPUT, MAKE DATA BASE QUERIES */
    /* USING THE CLIENT INPUT, CREATE CSS STYLE SHEETS */
    /* CREATE A SIX-CHARACTER UNIQUE IDENTIFIER */
    /* STORE THE IDENTIFIER IN THE DATA BASE, WITH THE CLIENT INPUT
     * AND THE GENERATED RESULTS FROM THE DATABASE + CSS */

    // USE HEREDOC TO CREATE THE HTML DOCUMENT
    $dat = htmlentities($_POST['data']);
    $htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<title>ANDY FANG PAGE</title>
</head>
<body>
<p>THE FORM SAID: $dat</p>
</body>
</html>
HTML5;

    // WRITE THE HTML DOCUMENT USING THE GENERATED HTML STRING
    echo $htm;
    die();
}

// IF THERE IS NOT POSTED DATA, PUT UP THE FORM TO RECEIVE THE DATA
$form = <<<EOD
<form method="post">
<input name="data" />
<input type="submit" />
</form>
EOD;
echo $form;

Open in new window

HTH, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.