Forum Moderators: coopster

Message Too Old, No Replies

PHP includes far too much

PHP picks up code beyond the include

         

jwm_Az

11:12 pm on Jan 24, 2008 (gmt 0)

10+ Year Member



I am new to PHP, but do have a programming background in general; I am trying to (greatly) reduce the number of .php files I need to maintain whenever minor adjustments to form variables and mail formatting is required.

So I've attempted to incorporate an INCLUDE statement to make this happen. What is happening is that the include statement not only grabs the file referenced, but it also grabs the rest of the php file which contains the original INCLUDE - and displays the entire lot on my confirmation web page, which entirely fails my goal and is ugly as well. I'm under immense pressure to get this working by EOB tomorrow.

Some snippets of the relevant code:

[FIRST BIT: the main .PHP file] -- executed via a form's SUBMIT action, this invokes 3 INCLUDE stmts . . .

<?php

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// Receiving variables and validation section
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

include 'vars_and_validation.php';

//=============================================================================
//
// Sending Email to Tax Manager
//
// First the email header is built, the the body of the email construction is
// handled . . . note that in the current implementation the first several
// lines are unique to each <partner.php> file since the parnter name is
// hard-coded, after which the rest of the email body is uniform Thus the
// first few "unique" concatenated lines are followed by an include of the
// remaining "generic" concatenated lines.
//=============================================================================

$pfw_header = "From: $email_confirmation_addy\n"
. "Reply-To: $email_confirmation_addy\n";
$pfw_subject = "Tax Assignment: $client_name";

$pfw_message = "Form Submitted By: $email_confirmation_addy\n"
. "\n"
. "==============================================\n"
. "\n"
. "Partner: James Murray-TEST-TEST\n";

include 'tax_manager_email_block.php';

@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//=============================================================================
//
// Sending Email to Visitor (partner or admin)
//
// First the email header is built, the the body of the email construction is
// handled . . . note that in the current implementation the first several
// lines are unique to each <partner.php> file since the parnter name is
// hard-coded, after which the rest of the email body is uniform Thus the
// first few "unique" concatenated lines are followed by an include of the
// remaining "generic" concatenated lines.
//=============================================================================

$pfw_header = "From: n@x.com\n"
. "Reply-To: n@x.com\n";
$pfw_subject = "Tax Assignment: $client_name";
$pfw_email_to_visitor = "$email_confirmation_addy";
$pfw_message = "Greetings,\n"
. "\n"
. "This email is confirmation that your Tax Assignment form submission was sent successfully with the following information:\n"
. "\n"
. "==============================================\n"
. "\n"
. "Partner: James Murray-TEST-TEST\n"
. "\n"
. "Your Email Address: $email_confirmation_addy\n";

include 'visitor_email_block.php';

@mail($pfw_email_to_visitor, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><b><font face='Arial' size='3' color='#000000'>Thank you. Your information was submitted successfully. You will receive a confirmation email shortly.</font></b></p>");
?>

[SECOND BIT: (with large sections removed) - vars_and_validation.php:]

//-----------------------------------------------------------------------------
// Receiving variables - Tax Assignment Form.
//
// Includes validation (tests of required fields)
//
// For inclusion into various Partner-specific files, e.g., billd.php, mo.php
//
//-----------------------------------------------------------------------------
@$email_to = addslashes($_POST['email_to']);
@$email_confirmation_addy = addslashes($_POST['email_confirmation_addy']);
@$recurring = addslashes($_POST['recurring']);
@$preparer_meeting = addslashes($_POST['preparer_meeting']);
@$partner_review = addslashes($_POST['partner_review']);
@$client_name = addslashes($_POST['client_name']);
@$client_number = addslashes($_POST['client_number']);
@$due_date = addslashes($_POST['due_date']);
@$dm_yes_no = addslashes($_POST['dm_yes_no']);
(lots removed...)
if (strlen($email_confirmation_addy) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please go back and select your name from the drop down list.</font></p>");
}
(file ends with above stmt)

]THIRD BIT: second INCLUDE, "tax_manager_email_block.php",
with much removed]

//-----------------------------------------------------------------------------
//
// Tax Manager email block, for inclusion in all <partner>.php files
//
// (Use in conjunction with vars_and_validation.php for variable names)
//
//-----------------------------------------------------------------------------

$pfw_message = $pfw_message

. "Recurring Work? $recurring\n"
. "Meeting with Preparer Needed? $preparer_meeting\n"
. "Tax Partner Review Needed? $partner_review\n"
. "Client Name: $client_name\n"
. "Client Number: $client_number\n"
. "Due Date to Partner: $due_date\n"
. "DM Document Reference? $dm_yes_no\n"
. "If Yes, DM Number: $dm_number\n"
. "Engagement Letter Needed? $eng_letter_yes_no\n"
. "\n";

[Net result of what appears in my IE display:]

//----------------------------------------------------------------------------- // Receiving variables - Tax Assignment Form. // // Includes validation (tests of required fields) // // For inclusion into various Partner-specific files, e.g., billd.php, mo.php // //----------------------------------------------------------------------------- @$email_to = addslashes($_POST['email_to']); @$email_confirmation_addy = addslashes($_POST['email_confirmation_addy']); @$recurring = addslashes($_POST['recurring']); @$preparer_meeting = addslashes($_POST['preparer_meeting']); @$partner_review = addslashes($_POST['partner_review']); @$client_name = addslashes($_POST['client_name']); @$client_number = addslashes($_POST['client_number']); @$due_date = addslashes($_POST['due_date']); @$dm_yes_no = addslashes($_POST['dm_yes_no']); @$dm_number = addslashes($_POST['dm_number']); @$eng_letter_yes_no = addslashes($_POST['eng_letter_yes_no']); @$est_hours = addslashes($_POST['est_hours']); @$pref_staff = addslashes($_POST['pref_staff']); @$pref_reviewer = addslashes($_POST['pref_reviewer']); @$py_preparer = addslashes($_POST['py_preparer']); @$py_reviewer = addslashes($_POST['py_reviewer']); @$detailed_description = addslashes($_POST['detailed_description']); //----------------------------------------------------------------------------- // variables added 11-28-07 for Won Sun //----------------------------------------------------------------------------- @$quickbooks_job_yes_no = addslashes($_POST['quickbooks_job_yes_no']); @$map_to_fx_yes_no = addslashes($_POST['map_to_fx_yes_no']); @$work_tieout_re_tr = addslashes($_POST['work_tieout_re_tr']); @$work_tieout_fixed_assets = addslashes($_POST['work_tieout_fixed_assets']); @$work_adjustre = addslashes($_POST['work_adjustre']); @$revenue_under = addslashes($_POST['revenue_under']); @$bank_recon = addslashes($_POST['bank_recon']); @$ar_ap_aging = addslashes($_POST['ar_ap_aging']); @$inventory = addslashes($_POST['inventory']); @$notes_receivable = addslashes($_POST['notes_receivable']); @$deliverable = addslashes($_POST['deliverable']); @$trial_bal_adj = addslashes($_POST['trial_bal_adj']); //----------------------------------------------------------------------------- // more variables added 12-11-07 for Darelene Hall //----------------------------------------------------------------------------- @$current_dep = addslashes($_POST['current_dep']); @$future_dep = addslashes($_POST['future_dep']); @$isf_post_aje = addslashes($_POST['isf_post_aje']); @$return_via_email = addslashes($_POST['return_via_email']); @$return_via_disc = addslashes($_POST['return_via_disc']); @$client_will_post = addslashes($_POST['client_will_post']); //----------------------------------------------------------------------------- // Validation-- standard required fields (note: form variable email_to is // currently pre-set in the .html file) //----------------------------------------------------------------------------- if (strlen($recurring) == 0 ) { die("
Please go back: Recurring Work? must be specified Y/N.

"); } if (strlen($client_name) == 0 ) { die("
Please go back: Client Name cannot be blank.

"); } if (strlen($client_number) == 0 ) { die("
Please go back: Client Number cannot be blank.

"); } if (strlen($due_date) == 0 ) { die("
Please go back: Due Date To Partner cannot be blank.

"); } if (strlen($dm_yes_no) == 0 ) { die("
Please go back: DM Document To Reference? must be specified Y/N.

"); } // Validation-- modification requested c. 12/6/07 to have Assignment Details required if (strlen($detailed_description) == 0 ) { die("
Please go back: Assignment Details cannot be blank.

"); } // Validation-- modification requested c. 1/7/08 to have Engagement Letter Needed? required if (strlen($eng_letter_yes_no) == 0 ) { die("
Please go back: Engagement Letter Needed must be specified Y/N.

"); } //----------------------------------------------------------------------------- // Engagement Letter Validation: *** adjust commented-out sections for testing! // if ($eng_letter_yes_no == "Yes") { //$pfw_email_to = "$email_to, #*$!@x.com"; $pfw_email_to = "$email_to, x2@x.com, x3@x.com"; } else {$pfw_email_to = "$email_to"; } if (strlen($email_confirmation_addy) == 0 ) { die("
Please go back and select your name from the drop down list.

"); } //----------------------------------------------------------------------------- // // Tax Manager email block, for inclusion in all .php files // // (Use in conjunction with vars_and_validation.php for variable names) // //----------------------------------------------------------------------------- $pfw_message = $pfw_message . "Recurring Work? $recurring\n" . "Meeting with Preparer Needed? $preparer_meeting\n" . "Tax Partner Review Needed? $partner_review\n" . "Client Name: $client_name\n" . "Client Number: $client_number\n" . "Due Date to Partner: $due_date\n" . "DM Document Reference? $dm_yes_no\n" . "If Yes, DM Number: $dm_number\n" . "Engagement Letter Needed? $eng_letter_yes_no\n" . "Estimated Hours: $est_hours\n" . "Preference on Staff: $pref_staff\n" . "Preference on Reviewer: $pref_reviewer\n" . "PY Preparer: $py_preparer\n" . "PY Reviewer: $py_reviewer\n" . "\n" . "Assignment Details: $detailed_description\n" . "\n" . "Detailed Description of Product Output (Deliverable): $deliverable\n" . "\n" . "Quickbooks job?: $quickbooks_job_yes_no\n" . "If Quickbooks job, map to FX Engagement?: $map_to_fx_yes_no\n" . "If Quickbooks job, work requirements --- \n" . "\n" . " Tie Out RE and input TR: $work_tieout_re_tr \n" . "\n" . " Tie Out RE, fixed assets, post-depreciation and tax \n" . " journal entry, input TR from source documents: $work_tieout_fixed_assets\n" . "\n" . " Adjust beginning of retained earnings through current \n" . " year revenue? $work_adjustre \n" . " But only if the difference is under: $revenue_under\n" . "\n" . " Bank Reconciliation: $bank_recon\n" . " A/R and A/P Aging: $ar_ap_aging\n" . " Inventory: $inventory\n" . " Notes Receivable and/or Payable Reconciliation: $notes_receivable\n" . "\n" . "Additional Output Requirements\n" . " Trial Balance & Adjusting Entries: $trial_bal_adj\n" . " Current Depreciation: $current_dep\n" . " Future Depreciation: $future_dep\n" . " Quickbooks: $quickbooks\n" . " ISF post AJEs and return file: $isf_post_aje\n" . " Return via email: $return_via_email\n" . " Return via disc: $return_via_disc\n" . " Client will post AJEs -do not return QB files- : $client_will_post\n" . "\n" . "==============================================\n" . "\n" . "Staff Assigned:\n" . "Reviewer Assigned:\n" . "Due Date to Reviewer:\n" . "\n" . "==============================================\n";//----------------------------------------------------------------------------- // // Visitor email block, for inclusion in all .php files // // (Use in conjunction with vars_and_validation.php for variable names) // //----------------------------------------------------------------------------- $pfw_message = $pfw_message . "\n" . "Recurring Work? $recurring\n" . "\n" . "Meeting with Preparer Needed? $preparer_meeting\n" . "\n" . "Tax Partner Review Needed? $partner_review\n" . "\n" . "Client Name: $client_name\n" . "\n" . "Client Number: $client_number\n" . "\n" . "Due Date to Partner: $due_date\n" . "\n" . "DM Document Reference? $dm_yes_no\n" . "\n" . "If Yes, DM Number: $dm_number\n" . "\n" . "Engagement Letter Needed? $eng_letter_yes_no\n" . "\n" . "Estimated Hours: $est_hours\n" . "\n" . "Preference on Staff: $pref_staff\n" . "\n" . "Preference on Reviewer: $pref_reviewer\n" . "\n" . "PY Preparer: $py_preparer\n" . "\n" . "PY Reviewer: $py_reviewer\n" . "\n" . "\n" . "Assignment Details: $detailed_description\n" . "\n" . "Detailed Description of Product Output (Deliverable): $deliverable\n" . "\n" . "Quickbooks job?: $quickbooks_job_yes_no\n" . "If Quickbooks job, map to FX Engagement?: $map_to_fx_yes_no\n" . "If Quickbooks job, work requirements --- \n" . "\n" . " Tie Out RE and input TR: $work_tieout_re_tr \n" . "\n" . " Tie Out RE, fixed assets, post-depreciation and tax \n" . " journal entry, input TR from source documents: $work_tieout_fixed_assets\n" . "\n" . " Adjust beginning of retained earnings through current \n" . " year revenue? $work_adjustre \n" . " But only if the difference is under: $revenue_under\n" . "\n" . " Bank Reconciliation: $bank_recon\n" . " A/R and A/P Aging: $ar_ap_aging\n" . " Inventory: $inventory\n" . " Notes Receivable and/or Payable Reconciliation: $notes_receivable\n" . "\n" . "Additional Output Requirements\n" . " Trial Balance & Adjusting Entries: $trial_bal_adj\n" . " Current Depreciation: $current_dep\n" . " Future Depreciation: $future_dep\n" . " Quickbooks: $quickbooks\n" . " ISF post AJEs and return file: $isf_post_aje\n" . " Return via email: $return_via_email\n" . " Return via disc: $return_via_disc\n" . " Client will post AJEs -do not return QB files- : $client_will_post\n" . "\n" . "==============================================\n" . "\n" . "\n";
Thank you. Your information was submitted successfully. You will receive a confirmation email shortly.

++++ The only line which should appear in my browser is the last echo stmtm ("Thank you. Your information...") Not only that, but I do in fact receive an email, which I am sure not-coincidentally contains only this:

Greetings,

This email is confirmation that your Tax Assignment form submission was sent successfully with the following information:

==============================================

Partner: James Murray-TEST-TEST

Your Email Address: x@x.com

I am sorry for so much detail, but after 6 hrs I can't see straight through what seems to me to be a trivial concept gone bad. Any help is GREATLY appreciated.

Thank you - James

[edited by: eelixduppy at 2:11 am (utc) on Jan. 25, 2008]
[edit reason] removed email [/edit]

eelixduppy

2:13 am on Jan 25, 2008 (gmt 0)



Make sure that all your php code, including that which is in the included files, is surrounded with the appropriate opening and closing tags:

<?php
#
#php code here
#
?>

phnord

5:42 am on Jan 25, 2008 (gmt 0)

10+ Year Member



include_once()

[php.net...]

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.