Jump to content

PHP form issue does not calculate.


JMack

Recommended Posts

I am having trouble getting this to work what am I doing wrong?

 

 

<p class="tenTitle"><p class="tenTitle">Module 4i: Profit / Loss Forecast<br />

 

 

<?php

 

   

// NAME STEP AND GIVE VALUE TO QUESTION VARIABLES SO ERROR CHECKING DOES NOT HAVE TO BE RECREATED FOR EVERY PAGE

$stepNumber = '4i';

$numQuestions = '9';

 

//get values from the $_post array:

$totalRev = $_POST['revenue'];

echo "totalRev: ".$totalRev."<br />";

$vCost = $_POST['cost'];

echo "vCost: ".$vCost."<br />";

$overheadCost = $_POST['overhead'];

echo "overheadCost: ".$overheadCost."<br />";

$taxes = $_POST['taxes'];

  echo "taxes: ".$taxes."<br />";

      $otherIncome = $_POST['other']; 

echo "other: ".$other."<br />";

 

 

//Calculate the gross profit:

$gross = $totalRev - $vCost;

echo "gross: ".$gross."<br />";

 

//Calculate the net profit:

$netProfit = $gross - $overheadCost;

echo "netProfit: ".$netProfit."<br />";

   

        // Calculate Income after taxes:

        $afterTaxes = $netProfit - $taxes;

echo "afterTaxes: ".$afterTaxes."<br />";

 

      // Calculate the Total Income:

        $totalIncome = $afterTaxes + $otherIncome;

echo "totalIncome: ".$TotalIncome."<br />";

 

// Print out the results

print ' <table border="1" cellpadding="4" cellspacing="3" width="350">

<tr>

    <td align="left" valign="top" border="1">

Total Revenue</td><td><input type="text" style="40" name="totalRev" value="'.$totalRev.'">

 

</td>

</tr>

           

            <tr>

  <td align="left" valign="top" border="1">

Less: Variable Cost</td><td><input type="text" style="40" name="vCost" value="'.$vCost.'">

 

</td>

</tr>

           

            <tr>

    <td align="left" valign="top" border="1">

Gross profit</td><td><input type="text" style="40" name="grossProfit" value="'.$GrossProfit.'">

 

</td>

</tr>

            <tr>

    <td align="left" valign="top" border="1">

Less: Overhead Cost</td><td>

<input type="text" style="40" name="overhead" value="'.$overheadCost.'">

</td>

</tr>

           

            <tr>

    <td align="left" valign="top" border="1">

Net Profit</td><td>

<input type="text" style="40" name="netProfit" value="'.$netProfit.'">

</td>

</tr>

            <tr>

    <td align="left" valign="top" border="1">

Taxes</td><td>

<input type="text" style="40" name="taxes" value="'.$taxes.'">

</td>

</tr>

            <tr>

    <td align="left" valign="top" border="1">

Profit After Taxes</td><td>

<input type="text" style="40" name="profitAfterTaxes" value="'.$profitAfterTaxes.'">

</td>

</tr>

            <tr>

    <td align="left" valign="top" border="1">

Other Income</td><td>

<input type="text" style="40" name="otherIncome" value="'.$otherIncome.'">

</td>

</tr>

            <tr>

    <td align="left" valign="top" border="1">

Net Income</td><td>

<input type="text" style="40" name="netIncome" value="'.$netIncome.'">

</td>

</tr>

          <tr>

              <td colspan="2" align="left" valign="top" border="1">

                <input type="submit" name="submit" id="Submit" value="Calculate" />

              </label></td>

              </tr>

 

</table></form>';

 

 

 

// DEFINE SESSION VARIABLES

$_SESSION['email']=$_POST['email'];

$_SESSION['emailCc']=$_POST['emailCc'];

$_SESSION['name']=$_POST['name'];

 

// DEFINE VARIABLES FOR MAILING TO USER AND BUZGATE

$to = '[email protected],'.$_POST['email'];

$email_subject = "Step ".$stepNumber." in Buzgate's Five Step Program";

 

for ($i = 1; $i <= $numQuestions; $i++) {

$eBodyQuestions .= $questions[$i]."\n"

.$_POST['data'.$i]."\n";

}

 

$email_body = $eBodyQuestions;

$headers = "From:".$_POST['email'];

 

//PLACE VARIABLES IN MAIL FUNCTION

mail($to, $email_subject, $email_body, $headers);

 

// DEFINE VARIABLES FOR MAILING TO USER AND BUZGATE

$toCc = $_POST['emailCc'];

$email_subjectCc = "Step ".$stepNumber." in Buzgate's Five Step Program from ".$_POST['name'];

$email_bodyCc = $_POST['name']." has sent this to you from www.BUZGate.org/8.0/".$state_abbrv_low."/".$page_name."\n

Please contact us at [email protected] if you have received this in error.\n";

 

$email_bodyCc = $email_bodyCc.$eBodyQuestions;

$headersCc = "From:[email protected]";

 

//PLACE VARIABLES IN CC MAIL FUNCTION

mail($toCc, $email_subjectCc, $email_bodyCc, $headersCc);

 

 

 

 

 

// DISPLAY RESPONSE TO CORRECTLY FILLING OUT FORM

echo "<p class='textCenter'>Thank you ".$_POST['name']." for completing Step ".$stepNumber."</p>

 

<p class='textCenter'><a href='five_steps_4summary.html'>Click here</a> to continue to 4Summary</p>

 

<p class='textCenter'>Or <a href='five_steps_".$stepNumber.".html'>try this form again</a>.</p>";

 

?>

Link to comment
https://forums.phpfreaks.com/topic/218305-php-form-issue-does-not-calculate/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.