Jump to content

How do I force images (content) to appear based on URL variable?


JetJagger

Recommended Posts

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.

Link to comment
Share on other sites

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

}

Link to comment
Share on other sites

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!

 

---

Link to comment
Share on other sites

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);
}

?>

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.