From: [EMAIL PROTECTED]
Operating system: Linux 2.2.16-22
PHP version: 4.0.4pl1
PHP Bug Type: *Session related
Bug description: corrupt http_post_vars when using session_start
When posting to a php script using sessions and pdf the HTTP_POST_VARS disappear. If
you change the variable $type to 1, which displays the variables from a text file,
everything works fine. Writing to a pdf file will show empty variables. If the
session_start() is commented out, the HTTP_POST_VARS return.
********Script 1***********
<?php
session_start();
session_register("s_CompanyId");
session_register("s_SiteId");
$s_CompanyId = 1;
$s_SiteId = 2;
?>
<html>
<head><title>s1</title></head>
<body class="svc-sch" onload="javascript: init();">
<form name="claims" method="post" action="s2.php">
<input type="hidden" name="form_name" value="claims">
<input type="hidden" name="site_id" value="<?php echo $s_SiteId; ?>">
<input type="hidden" name="co_id" value="<?php echo $s_CompanyId; ?>">
<input type="submit" name="print" value="Print">
</form>
</body>
</html>
********Script 2***********
<?php
session_start();
$my_site_id = $HTTP_POST_VARS['site_id'];
$my_co_id = $HTTP_POST_VARS['co_id'];
$fn=$HTTP_POST_VARS['form_name'];
// change to $type = 1; works
$type = 0;
$page_width = 612; // width of page
$page_height = 792; // height of page
// open document
if( $type == 0 )
$file_name = "/tmp/claim.pdf";
else if( $type == 1 )
$file_name = "/tmp/claim.txt";
$fp = fopen( $file_name, "w" );
//
// PDF
//
if( $type == 0 )
{
$pdf = PDF_open( $fp );
// begin page
PDF_begin_page( $pdf, $page_width, $page_height ); // 8.5" x 11.0"
$page = $page + 1;
// add bookmark
PDF_add_bookmark( $pdf, $page );
// set font
PDF_set_font( $pdf, "Courier", 10, "host" );
PDF_set_value( $pdf, "textrendering", 0 );
PDF_show_xy( $pdf, "form_name=$fn", 50, 350 );
PDF_show_xy( $pdf, "co_id=$my_co_id", 50, 360 );
PDF_show_xy( $pdf, "site_id=$my_site_id", 50, 370 );
PDF_show_xy( $pdf, "s_CompanyId=$s_CompanyId", 50, 380 );
PDF_show_xy( $pdf, "s_SiteId=$s_SiteId", 50, 390 );
// end page
PDF_end_page( $pdf );
// close document
PDF_close( $pdf );
}
else if( $type == 1 )
{
fwrite( $fp, "form_name=$fn\n" );
fwrite( $fp, "co_id=$my_co_id\n" );
fwrite( $fp, "site_id=$my_site_id\n" );
fwrite( $fp, "s_CompanyId=$s_CompanyId\n" );
fwrite( $fp, "s_SiteId=$s_SiteId\n" );
}
fflush( $fp );
fclose( $fp );
// transmit file
$len = filesize( $file_name );
if( $type == 0 )
header( "Content-Type: application/pdf" );
else if( $type == 1 )
header( "Content-Type: text/plain" );
header( "Content-Length: $len" );
/*
header( "Pragma: " );
header( "Last-Modified: ".gmdate("D, d M Y H:i:s", time())." GMT" );
header( "Expires: ".gmdate("D, d M Y H:i:s", time()+5)." GMT" );
header( "Cache-Control: must-revalidate, max-age=5, s-max-age=5" );
*/
header("Content-Disposition: inline; filename=claims.pdf");
$rtn=readfile( $file_name );
?>
--
Edit Bug report at: http://bugs.php.net/?id=10000&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]