views:

34

answers:

2

i hate situations, when i can't explain the behavior of compiler. So help me please to understand, how it possible...

i have two php files - index.php, and admin.php. in index.php i make registration, and captcha checking, and if they are correct, i set the value of session variable to somevalue,(at first it has anothervalue) and redirect client to admin.php where the CMS is! And now, what is the problem, i have a module in admin.php which has an img element, src of which i generate when it clicked(using jquery...), but at first it has src empty

<img src="" /> and due to it, i lose the new value of session variable(it becomes anothervalue again). IT happens only in IE!!!

BUT if i set any value to src attribute, it works fine!!!

<img src="some.jpg" /> works fine

help me please to understund such behavior

+4  A: 

The URI "" resolves to the current URI. So the browser tries to load the page it is currently on as an image (and all the associated PHP is run again).

Don't set images with an empty src attribute.

David Dorward
Thanks, Thanks, Thansk:)
Syom
indeed, why not use a data:// uri as a temporary placeholder
nathan
If you don't have a src, then don't have an img. If you want to dynamically add one, then add the whole image.
David Dorward
Actually this tiny little problem once resulted in two days heavy debugging of a PHP code, there an SQL-statement was executed twice randomly. Eventually I found out it was the empty src attribute... Sometimes such things are hard to find is you're looking for something else.
nikic
+2  A: 

If the src attribute is empty, IE makes a request to the directory in which the current page is located. Since this is probably handled by index.php, it would seem that that's the script responsible for changing the session variable.

Long story short: don't use an emptry src attribute.

Victor Welling