|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-14 23:33 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
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 ); ?>