JetJagger Posted October 24, 2008 Share Posted October 24, 2008 PHP 4 PLEASE READ CAREFULLY AS I NEED A SPECIFIC TYPE OF SOLUTION... Situation: I have a Website that needs content (images and php include files) to change based on a URL variable located at the end of the URL path. I expect that the public URL string would appear (loosely) as: Client A: http://www.mywebsite.com/php=id?001 (shows only the content related to Client A) Client B: http://www.mywebsite.com/php=id?002 (shows only the content related to Client B) Client C: http://www.mywebsite.com/php=id?003 (shows only the content related to Client C) I need a script that looks at the URL-with-variable to determine what content to place in the Web page, so if the variable AFTER '.com' equals 'php=id?001' (or whatever), then the script in the Web page will get content for 'Client A' ONLY ~ while leaving the other page content intact. Execution: NO SQL DATABASE REQUIRED. This can operate from a flat array for all I care (since I don't know how to set up a MySQL database anyway and don't really don't have the time to learn right now). Like I said, I just need a script that looks at the URL string for the variable (instead looking in a database) and determines what content gets inserted based on that. Wrench: All content to be included via the variable (at the end of the URL) will be pulled-in by < includes >. For example, if a header image is going to be inserted into the page for Client A, then the file containing the image path will be called 'copyHeaderAd.php'*** (which contains the text path of < img src="http://client.mywebsite.com/images/headerAd.php" > in the PHP file). So.... A) Public goes to page B) Browser sees script that says to look at ID variable in URL C) Script in page searches for flat array (that says 'if ID equals 'this', then 'get php include file from here') and inserts appropriate php include file. D) Therefore, If Client A's ID=001, then get content called 'copyHeaderAd.php' containing image path and display image 'headAd.php'. ***The reason for the image being in a PHP include file is because different images will have different file names. We want to keep the .php page file name consistent (copyHeaderAd.php) while allowing image names to be different (joesHeaderAd.jpg, janesHeaderAd.php, stevesHeaderAd, etc.). So, we need to include the .php file instead of directly including the image file by name. Any help would be greatly appreciated. Also, anyone who can provide this script solution will get a free ad in this project (which is an online magazine that caters to small business owner across the USA who consistently keep Web development help. We already have many clients using a different solution who would instantly convert to this new app). Thanks to anyone who can help. Quote Link to comment Share on other sites More sharing options...
JetJagger Posted October 24, 2008 Author Share Posted October 24, 2008 Could this be accomplished with Cookies? Quote Link to comment Share on other sites More sharing options...
n3ightjay Posted October 24, 2008 Share Posted October 24, 2008 you urls are set up wrong : http://www.mywebsite.com/php=id?001 should be: http://www.mywebsite.com/php?id=001 then you could just do something like if($_GET['id'] == 001){ include(whatever.php); } but if you have alot of users you might want to learn a sql or you could name the include files with there ids instead and make a call like: if(isset($_GET['id'])){ include('header' . $_GET['id'] . '.php'); // header001.php for example } Quote Link to comment Share on other sites More sharing options...
n3ightjay Posted October 24, 2008 Share Posted October 24, 2008 Could this be accomplished with Cookies? yes you could do that to Quote Link to comment Share on other sites More sharing options...
JetJagger Posted October 24, 2008 Author Share Posted October 24, 2008 n3ightjay, would you recommend cookies over the first solution or not? ...and I am learning SQL. Bought four books, so lots of reading to do! Quote Link to comment Share on other sites More sharing options...
JetJagger Posted October 24, 2008 Author Share Posted October 24, 2008 Okay, here's the modified version of the same question.... Instead of pulling in content based on a PHP ID variable, is it possible to pull in content based on the TLD (such as 'www.clientswebsite.com') So, if URL equals 'clientswebsite.com', then insert 'this file or image'. If URL equals 'anotherclientwebsite.com', then insert 'this file or image' instead. I think what I really need is to have content inserted based on the domain name, not the domain name and not a variable specifically. Thanks! --- Quote Link to comment Share on other sites More sharing options...
n3ightjay Posted October 24, 2008 Share Posted October 24, 2008 Instead of pulling in content based on a PHP ID variable, is it possible to pull in content based on the TLD (such as 'www.clientswebsite.com') So, if URL equals 'clientswebsite.com', then insert 'this file or image'. If URL equals 'anotherclientwebsite.com', then insert 'this file or image' instead. Yes it is : (definately not using cookies) something like: <? if('$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"' == "www.clientswebsite.com"){ include(whatever); }elseif('$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"' == "www.anotherclientwebsite.com"){ include(whateverElse); } ?> Quote Link to comment Share on other sites More sharing options...
JetJagger Posted October 24, 2008 Author Share Posted October 24, 2008 Cool, n3ightjay. I'll see if this works for this project. I appreciate the help. IM me is you want to take me up on that offer to place an ad in the completed version of the project. Obviously I'll send a link to you first so you can review it. Ciao! Quote Link to comment 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.