Link to home
Start Free TrialLog in
Avatar of Andy_Fang
Andy_Fang

asked on

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"
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Yes, that is entirely feasible.  What is the question?
Avatar of Andy_Fang
Andy_Fang

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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