papaface Posted September 25, 2007 Share Posted September 25, 2007 Hello, I am trying to pass a variable through an image. Like this: <img src="http://www.*****.com/test.php?url=1234" /> In test.php I have this code: <?php session_start(); $_SESSION['url'] = $_GET['url']; ?> But this doesnt seem to set $_SESSION['url'] to 1234 Does anyone know a way I can get this to work? regards Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/ Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 Perhaps if you can describe the desired end result I can better assist. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354531 Share on other sites More sharing options...
TheFilmGod Posted September 25, 2007 Share Posted September 25, 2007 how can you pass the variable via image src?? - you can't!!! You can do it through a link or an address, not an image src. Try <a href="http://www.website.com/test.php?url=1234"><img src"..." /></a> LIke that? Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354532 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 Scripts can be called from an image src so I don't see why variables cant be used in it aswell.... How do you think captchas are generated. I am well aware you can pass a variable through a link. Perhaps if you can describe the desired end result I can better assist. I want to call the image file, create a session var with the parameter in the image src code. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354533 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 The image src wouldnt be an image it would be a script remember. So nothing would load. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354537 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 You're right, it does seem that you would be able to pass variables, even if the script is being called as an image source. I specifically recall seeing a script that was used to generate an image and it contained variable references and declarations. Maybe there's a limit on the type of session-related activity you can perform when accessing a script this way? Best of luck! Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354538 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 The image src wouldnt be an image it would be a script remember. So nothing would load. You can use the header() to display an image. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354539 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 I think this may have something to do with the fact the variable isnt in an address bar, so therefore $_GET can't be used ??? You can use the header() to display an image. I don't want to display an image. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354541 Share on other sites More sharing options...
TheFilmGod Posted September 25, 2007 Share Posted September 25, 2007 I think this may have something to do with the fact the variable isnt in an address bar, so therefore $_GET can't be used ??? You can use the header() to display an image. I don't want to display an image. Lol. That is what I was talking about! DuH! Hit the books mister! Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354542 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 Could be, why exactly are you using an <img> tag if you're not displaying an image? Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354544 Share on other sites More sharing options...
TheFilmGod Posted September 25, 2007 Share Posted September 25, 2007 Could be, why exactly are you using an <img> tag if you're not displaying an image? No. That is right. Come on 1st grade php. You can't extract $_GET parameters unless they are in the address bar. Try using $_FILE instead or $_SESSION Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354546 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 No. That is right. Come on 1st grade php. You can't extract $_GET parameters unless they are in the address bar. Try using $_FILE instead or $_SESSION What the hell is wrong with you. Cant you just reply in a kind manner, than in an offensive and immature tone. Try using $_FILE instead or $_SESSION and only a 1st grader in PHP would offer those two as a solution. Could be, why exactly are you using an <img> tag if you're not displaying an image? Its complicated lol. An image is produced it is a captcha script. I just wanted to simplify things as it isn't really an important point to make. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354548 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 I think this may have something to do with the fact the variable isnt in an address bar, so therefore $_GET can't be used ??? You can use the header() to display an image. I don't want to display an image. Lol. That is what I was talking about! DuH! Hit the books mister! Just to clarify, FilmGod, you can "generate" an image using a PHP script. I could link to <img src="foo.php"> and have it display as an image. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354549 Share on other sites More sharing options...
TheFilmGod Posted September 25, 2007 Share Posted September 25, 2007 I think this may have something to do with the fact the variable isnt in an address bar, so therefore $_GET can't be used ??? You can use the header() to display an image. I don't want to display an image. Lol. That is what I was talking about! DuH! Hit the books mister! Just to clarify, FilmGod, you can "generate" an image using a PHP script. I could link to <img src="foo.php"> and have it display as an image. huh? src="foo.php". Don't pull a fast one on me. That aint' no image. You can use <a href=""></a> instead. Why image anyway. 1st grade html come on! Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354550 Share on other sites More sharing options...
TheFilmGod Posted September 25, 2007 Share Posted September 25, 2007 Actually. I take that back. But it would have been better to generate the image before and then have it in the cache or watever before hand. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354551 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 For goodness sake! and image can be called from a php script. You obviously do not know what you are talking about, and are therefore posting irrelevant info in my thread. Go elsewhere! Now back on topic. Theoretically you should be able to post the vars in the src. hmmm.. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354552 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 Actually. I take that back. But it would have been better to generate the image before and then have it in the cache or watever before hand. You expertise is no longer required FilmGod ha ha. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354553 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 For goodness sake! and image can be called from a php script. You obviously do not know what you are talking about, and are therefore posting irrelevant info in my thread. Go elsewhere! Now back on topic. Theoretically you should be able to post the vars in the src. hmmm.. Yes, you should. I know I've seen it work with $_GET's before, just not sure about sessions. I can see why the session data wouldn't be retained if you're using the img src to set it, but not exactly sure what the facts are on the matter. Let me do some quick digging. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354555 Share on other sites More sharing options...
trq Posted September 25, 2007 Share Posted September 25, 2007 Why image anyway. 1st grade html come on! Seriously, you have no idea what you are on about. You can use php to generate images. I have often used img src tags like... <image src="image.php?id=foo"> You then have your image.php file generate the image using the gd functions and apprpriate headers. Funnily enough, sourcing an image via the src tag makes a GET request. papaface.... can we please see your actual code? Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354557 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 hmm. I have just tried it and I think it is working. Which is strange as it wasnt before. Give me to minutes to clarify. Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354560 Share on other sites More sharing options...
papaface Posted September 25, 2007 Author Share Posted September 25, 2007 Ahhh it is lol. Thanks for your help guys! Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354561 Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 Good, because it was confusing that it wouldn't work Quote Link to comment https://forums.phpfreaks.com/topic/70559-solved-is-this-possible-variables-through-img-src/#findComment-354563 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.