SurfDog;11035563 wrote:
didn't check guidelines so I hope I'm ok posting a link to what I have so far...
links are good. But if you have code, post is directly using [noparse]
, [code] or [code=html][/noparse] tags.
[QUOTE=SurfDog;11035563]
dynamically create subdomains on our root domain
[/quote]
If you are thinking along the lines of having one subdomain for each user or each sale or whatever, then you are most likely trying to do things in a weird way. However, if those subdomains relate to real estate salesmen, it could make sense to create one subdomain for each person, since it's easy for customers to remember those urls "smith.kwmds.com", "brown.kwmds.com" etc.
[/quote]
which would then be used (the subdomain’s address) to pass a unique identifier to create the dynamic page
[/quote]
Actually really simple in practice. Assuming your web server is running php, you have two different and equally simple options.
Assuming each subdomain is mapped to its own document root on the server,
[code]
smith.kwmds.com -> /data/www/smith
brown.kwmds.com -> /data/www/brown
You'd keep all files common to all subdomains under /data/www but above the document roots. For example /data/www/include, /data/www/controller
youd also set "index" or "default page" or whatever the conf setting is called to use "index.php", so that smith.kwmds.com would find the file /data/www/smith/index.php
Option 1, in index php, define these values in the index.php files that are specific to each subdomain
<?php
# in smith's file
$site_id = 1;
# in browns file
$site_id = 2;
# in both files
require '/data/www/include/conf.php';
However, I mainly show this so that you understand that it's no less difficult to have two separate subdomains (on the same web server) do some things differently, before making use of other files which are the same in both cases than it is for two different urls on the same domain to do it. Compare the above scenario with two urls
http://example.com/file1.php
http://example.com/file2.php
Assuming those urls map to /data/www/file1.php and /data/www/file2.php, it's evident that you could do the same thing here as we previously did above. It may also be worthwhile to know that urls doesn't necessarily map directly to "the same files". They could both map to the exact same disk file. Or the file2.php url could map to the file1.php file and the file1.php url could map to the directory /data/www and list the contents of the directory
The second way of using the subdomains to differentiate between requests is to simply check which domain was requested. Where "simply" only becomes simply if you have configured your web server properly. If so, then you may use $_SERVER['SERVER_NAME']. You shouldn't rely on my lack of expertise when it comes to system configuration, but I believe that you need to disable your web servers default host / point it somewhere harmless and use named virtual hosts.
As for the data storage, I recommend learnig how to use a datbase. XML-files are hard to modify, hard to search, needs to be parsed which leads to longer development times (money sink), higher risk of errors and inefficiency. If you need to store stuff, retrieve it based on keys and update the information - for the love of computer science - do not store it as xml files. It can be done, but I strongly recommend against it. And should the use case be that you rarely / never update this information, like I said the first time: store them in an appropriate format (for this case - HTML), then just include them in your html page. Using a php script to generate the html output, you'd easily achieve this by
<?php
# possibly doing things that needs doing before sending output, such as
# session_start() - if you NEED sessions
# header(...)
# set_cookie(...)
?><!DOCTYPE html>
...
<body>
...
Here comes the specific information…
<?php
require 'some_user_file.html';
?>
There endeth the spceific information.
which, when combining the info I provided initially with this approach, in its simplest form would look like
/data/www/brown/index.php
<?php
DEFINE("SALES_CONTACT_FILENAME", "brown.html");
DEFINE("PAGE_TITLE_PREPEND", "Brown");
require '/data/www/include/common.php';
And /data/www/include/common.php would be the html output generator,
<!DOCTYPE html>
<html>
<head>
<title>
<?php echo PAGE_TITLE_PREPEND . " | ";?>Keller Williams Real Estate
</title>
<!-- sales person information -->
<?php
require SALES_CONTACT_FILENAME;
?>
...
But truthfully, I still don't understand what you actually want to do or why. For example, a "user" to me is the person requesting the page. And why would their name appear at the bottom of the screen? A user may of course also be a sales person requesting a page that lets them add/modify their own contact information. But then you have two seprate groups of users, internal users / sales users and end users / clients. And that means you have to be very very specific when talking to other people about who a user is in each case, what and why they are allowed to do etc.