Jump to content

[SOLVED] Is this possible? Variables through img src


papaface

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

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.