intodesi Posted April 21, 2008 Share Posted April 21, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/ Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523342 Share on other sites More sharing options...
intodesi Posted April 21, 2008 Author Share Posted April 21, 2008 I dont know, What all does that do, and thanks Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523359 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 creates a file, but it only creates one with a set name, Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523365 Share on other sites More sharing options...
intodesi Posted April 21, 2008 Author Share Posted April 21, 2008 hmm then I dont think it would work.. I wonder for mysql could create files on the fly. Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523373 Share on other sites More sharing options...
ToonMariner Posted April 21, 2008 Share Posted April 21, 2008 ??????????? 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... Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523385 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Because you're hellbent on making your clients feel special, use mod_rewrite to make it like http://www.yourdomain.com/client/CLIENTNAME, but really have it as http://www.yourdomain.com/client_page.php?c=#. =P Google it a bit. Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523398 Share on other sites More sharing options...
intodesi Posted April 21, 2008 Author Share Posted April 21, 2008 hehe Dark..I actually found another solution....Clients dont need to feel special.. they can all be directed to a single client page i just needed to fix that client page 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 Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523406 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 xD Glad you solved your problem. =) Quote Link to comment https://forums.phpfreaks.com/topic/102227-solved-dynamic-pages/#findComment-523416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.