This is probably easy but I have no idea how to do it.
I want to be able to use a URL string, e.g. http://www.mysite.com/index.php?cssfile=customer1
it'll then somehow find a CSS file called "customer1.css" and incorporate it into the page, this'll be used for several customers who'll just be given different urls ending in (e.g.) cssfile=customer2 or cssfile=customer3 etc. I'll be manually uploading the relevant CSS files in the same directory so I just need to find some way of incorporating them based on the URL.
Any help is appreciated
Thanks
how would I do this?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You can get the value of the cssfile variable from the $_GET array, to get this value and set it to a default if it doesn't exist you could do:
Then you'll have a variable in the script called $cssfile which you can use when writing the HTML to include the CSS file. You may want to also include a bit of script that checks that the file exists (in case the user modifies the querystring). You can use the [php_man]file_exists[/php_man]() function to do this.
Mac
Code: Select all
// first get rid of any extra spaces that have been added to the URL
// query string variables
foreach ($_GET as $key => $value) {
$_GET[$key] = trim($value);
}
// now check whether there is a value for cssfile and if not set a default
if (!empty($_GET['cssfile']) {
$cssfile = $_GET['cssfile'];
} else {
$cssfile = 'customer1';
}Mac