From:             steamboy at gmail dot com
Operating system: Win 98, Linux
PHP version:      4.4.3
PHP Bug Type:     Unknown/Other Function
Bug description:  Javascript line interfering with setcookie()

Description:
------------
I'm sorry, I could not check the bug with the latest version of php (only
with 4.3.11), BUT before closing this topic, please try the code I posted
because the bug is so peculiar, I would be surprised if it had been
reported !

One line of javascript (displaying an html image tag with document.write),
prevents the setcookie function to work correctly when the value is given
with some conditional statements (using isset, or hiding an error with
@).

Simply enter a word in the input field.

Reproduce code:
---------------
<?php

if (!isset($_POST['aa'])) {$ax='00';} else {$ax=$_POST['aa'];}

setcookie('test',$ax);
var_dump($ax);

?>

<script type="text/javascript"> document.write('<img src>') </script>

<form method="post" action="" name="test">
<input type="text" name="aa"><br><br>
<input type="submit" value="Ok">

</form>

Expected result:
----------------
It should set a cookie named 'test' with the value you have entered in the
input field.

Actual result:
--------------
Instead it will set the '00' value to the cookie, even though dumping the
variable produces the expected result, that is the content of the input
field !

However, if you remove the javascript line, it will set the cookie with
the correct value !

-- 
Edit bug report at http://bugs.php.net/?id=38418&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38418&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38418&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38418&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38418&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38418&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38418&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38418&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38418&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38418&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38418&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38418&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38418&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38418&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38418&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38418&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38418&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38418&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38418&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38418&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38418&r=mysqlcfg

Reply via email to