Jump to content

[SOLVED] possible to get variables from an image tag


tryingtolearn

Recommended Posts

Im wondering if it is possible to have an image tag provide two different urls to a php page

that will check if url to image 1 exists - if it does, display it but if it doesnt go to url 2 and display it.

 

So the html would be something like

<img src="www.alternate_img.php?img1=www.url_to_img_1&img2=www.url_to_img_2">

 

how do you pick up the ?img1=www.url_to_img_1&img2=www.url_to_img_2

in alternate_img.php to check if they exist to display the image in the html img tag?

 

 

Can you do something like that?

This is what I started with but both variables always come back as 0

// Check for a primary Image URL.
if (isset($_GET['img1'])) { // Page is first accessed.
$purl = $_GET['img1'];
} else { // Big problem!
$purl = 0;
}

// Check for a alternate Image URL.
if (isset($_GET['img2'])) { // Page is first accessed.
$aurl = $_GET['img2'];
} else { // Big problem!
$aurl = 0;
}
if (($purl == 0)||($aurl == 0)) { // Do not proceed!
header("content-type: image/jpeg");
$sig_loc = "noimg.jpg";	
$sig = imagecreatefromjpeg($sig_loc);
imagejpeg($sig);	
exit(); // Terminate execution of the script.
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.