php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10000 corrupt http_post_vars when using session_start
Submitted: 2001-03-26 12:51 UTC Modified: 2001-06-14 23:33 UTC
From: john_rief at yahoo dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.0.4pl1 OS: Linux 2.2.16-22
Private report: No CVE-ID: None
 [2001-03-26 12:51 UTC] john_rief at yahoo dot com
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 );
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-14 23:33 UTC] sniper@php.net
Can't reproduce. Get the latest RC from here:

http://www.php.net/~andi/php-4.0.6RC3.tar.gz 

(if that doesn't work, try with RC4)

And if it still doesn't work, submit a new bug report,
with SHORT example script. Not over 15 lines..


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC