tryingtolearn Posted October 24, 2009 Share Posted October 24, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/178831-solved-possible-to-get-variables-from-an-image-tag/ Share on other sites More sharing options...
tryingtolearn Posted October 24, 2009 Author Share Posted October 24, 2009 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. } Quote Link to comment https://forums.phpfreaks.com/topic/178831-solved-possible-to-get-variables-from-an-image-tag/#findComment-943425 Share on other sites More sharing options...
severndigital Posted October 24, 2009 Share Posted October 24, 2009 try using !empty($_GET['img1']) //instead of isset($_GET['img1']); Quote Link to comment https://forums.phpfreaks.com/topic/178831-solved-possible-to-get-variables-from-an-image-tag/#findComment-943428 Share on other sites More sharing options...
tryingtolearn Posted October 24, 2009 Author Share Posted October 24, 2009 Hmmm tried it but no luck, still 0 Quote Link to comment https://forums.phpfreaks.com/topic/178831-solved-possible-to-get-variables-from-an-image-tag/#findComment-943433 Share on other sites More sharing options...
tryingtolearn Posted October 24, 2009 Author Share Posted October 24, 2009 changed $purl = 0; and $aurl = 0 TO $purl="WRONG" $aurl="WRONG" and its working. Quote Link to comment https://forums.phpfreaks.com/topic/178831-solved-possible-to-get-variables-from-an-image-tag/#findComment-943462 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.