Jump to content

[SOLVED] dynamic pages?


intodesi

Recommended Posts

Is it possible to have php create pages based on a template for you?

 

I have a client system on my website,  they can register and login to their own pages, but as of right now I have to create those pages manually.

 

what I want is to have it when a user activates their account their page gets created for them in a specific directory from a template page.

 

the template page doesnt need to be modified for each user, because its mostly generic except one line, which says that if the person viewing the page is not the owner of that page, then they can view it, so I would need to dynamically handle this.

 

the template I would use is

 

 

<?

session_start();

if ($_SESSION['u_name'] != USERNAME)

{                                                         

echo "You Do not have the required permisions to view this Page!<br />";

echo "please go back to the client area <<sites url>>;

exit;

}

echo "Welcome ". $_SESSION['f_name'] ." from ". $_SESSION['c_name'] ."!

    You have made it to your client page!<br /><br />";

?>

 

<?

$uid = $_SESSION['uid'];

require 'clients/includes/conf_session.php';

/* SQL stuff here */

$sql = "SELECT * FROM projects "." WHERE uid='$uid'";

$result = mysql_query($sql);

/* Forgot the semicolon here */

?>

<h2>Work Orders</h2>

<table width="661" border="2" cellspacing="2">

  <tr>

    <th width="129" scope="col">Project Name</th>

    <th width="122" scope="col">Project Status</th>

    <th width="151" scope="col">Invoice</th>

    <th width="157" scope="col">Last Updated</th>

  </tr>

  <tr>

  <?

  while($row = mysql_fetch_array($result)){

  echo  ("<td>$row[project]</td>");

  echo  ("<td>$row[status]</td>");

  echo  ("<td>$row[invoice]</td>");

  echo  ("<td>$row[l_uodate]</td>");

  echo  "</tr>";}

  ?>

</table>

<p><a href="index.php?c=submit_job">Submit Job</a></p>

 

The USERNAME

 

would need to be modified (hopefully php can do this) when the page is created so that it reflects the clients username it was created for.

 

any idea's?

 

And thanks ahead of time.

 

Link to comment
Share on other sites

can you use something like this

<?php

// Random Game Design: PHP Website Template
//  Version 1
//  Copyright Dean Whitehouse, 2008
require_once 'install.php';

$config_file = "config.inc.php";

$fw=fopen($config_file,"w+") 
or die("Unable to open file!");	// Unable to open file

$config_host = "\$dbhost = \"".$dbhost."\";\n";
$config_user = "\$dbuser = \"".$dbuser."\";\n";
$config_pass = "\$dbpass = \"".$dbpass."\";\n";
$config_db = "\$dbname = \"".$dbname."\";";

$config_write = $config_host.$config_user.$config_pass.$config_db;

fwrite($fw, "<?php\n".$config_write."\n?>");

fclose($fw);

?>

with what you want

Link to comment
Share on other sites

???????????

 

yes php can do this - providing you know what the templates should be and what content requires manipulation you can do what you want - either write the code generated to a file or to the screen - it matters not.

 

YOu could even write php to write another php script provided you have defined what you want it to accomplish - thats the hard part - coding it is a piece of piss...

Link to comment
Share on other sites

hehe Dark..I actually found another solution....Clients dont need to feel special.. they can all be directed to a single client page :P

 

i just needed to fix that client page :P

 

if ($_SESSION['is_valid'] != true)

 

instead of

 

if ($_SESSION['u_name'] != USERNAME)

 

and then Dark.. that throws out my need to dynamically stick the client urls into my array...

 

two birds one stone..

 

But I do appreciate the help :)

 

When I post on the forum i usually still continue to find a solution to my questions the old fashion way.. but most of the time, these forums help me either look in the right direction.. or give me the code examples to let me get done what I need to get done :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.