ID:               26482
 Updated by:       [EMAIL PROTECTED]
 Reported By:      andreas dot schmitter at swisslife dot ch
-Status:           Open
+Status:           Bogus
 Bug Type:         Session related
 Operating System: WIN2000 Prof
 PHP Version:      4.3.4
 New Comment:

Given the incomplete buggy script, of course it won't work.
This works just fine:

<?php

session_start();
$ref='foo';
$msg = array ('cancel' => 'cancel');
  
?>
<form name="goback" method="post"
<?php if ($ref=='actlist') {   
  echo ' action="act_list.php">';
} else {    
  echo ' action="user_home.php">';
} 
?>
<input type="hidden" name="ref" value="<?php echo $ref;?>">    
<input type="submit" class="button" name="back" value="<?php echo
$msg['cancel'];?>">
</form>

Also note: trans-sid is NOT fool-proof. You can't just expect any buggy
html to work..
And what you do is pretty weird way to output html anyway.
ALWAYS separate HTML from code as much as possible..e.g.

if ($ref=='actlist') {
  $action = 'act_list.php';
} else {        
  $action = 'user_home.php';
}

And then just do:
<form name="goback" method="post" action="<?php echo $action; ?>">



Previous Comments:
------------------------------------------------------------------------

[2003-12-01 04:59:01] andreas dot schmitter at swisslife dot ch

Description:
------------
For some reasons i can not use cookies for session handling and
therfore use the only the transparent session id, which works fine. But
recently i got the following problem: 
I have a form which has different action based on a variable ($ref).
With the first code snippet 
(output of the Form-Tag as one string)
it worked fine. But with the second snippet (Form-Tag is split) the
session id is somehow lost. 

Both ways the form worked and all the variables are passed correctly.

Regards
Andreas Schmitter    

Reproduce code:
---------------
<?php if ($ref=='actlist') {
echo '<form name="goback" method="post" action="act_list.php">';
} else {        
echo '<form name="goback" method="post" action="user_home.php">';
}       
?>
<input type="hidden" name="ref" value="<?php echo $ref ; ?>">           
<input type="submit" class="button" name="back" value="<?php echo
$msg['cancel'];?>">
</form>
----------------------------------------------------------
<form name="goback" method="post"
<?php if ($ref=='actlist') {
echo ' action="act_list.php">';
} else {        
echo ' action="user_home.php">';
}       
?>
<input type="hidden" name="ref" value="<?php echo $ref ; ?>">           
<input type="submit" class="button" name="back" value="<?php echo
$msg['cancel'];?>">
</form>

Expected result:
----------------
Result of Code Snippet 1:
<form name="goback" method="post" action="user_home.php"><input
type="hidden" name="PHPSESSID" value="066a2f65204eccb562831f3f1d8d88e5"
/><input type="hidden" name="ref" value="uhome">                
<input type="submit" class="button" name="back" value="Cancel">
-----------------------------
Result of Code Snippet 2:
<form name="goback" method="post"               
 action="user_home.php"><input type="hidden" name="ref"
value="uhome">          
<input type="submit" class="button" name="back" value="Cancel">



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=26482&edit=1

Reply via email to