title: Passing function to another page in PHP
body: <p>So this has been bugging me for sometime, I want to pass a calculation which I have stored in a function onto another page, I can pass field entries no problem (sorry im newish at PHP) but how do i pass my calculation from:</p>
  
  <p>// calculation section (calculator.php) - this is a include on every page
  The calculation is made by a users entries which is in a include on every page</p>
  
  <p>// The thank-you.php page outputs a thank you comment and sends the email
  I receive all the other info fine but the function won't come through in my email.
  The output from the calculation is also stored in calculator.php which is the include but it outputs to the screen fine just not to my email :(.</p>
  
  <p>Am I missing something?</p>
  
  <p>Sorry (edit) here is my code:</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  
  
  if(isset($_POST['name']) &amp;&amp; isset($_POST['to'])){
  
  ini_set('date.timezone', 'Europe/Madrid');
  $now = date("H:i");
  
  $cutoff = "06:00";
  $higherthan = "22:00";
  
  
      $name = $_REQUEST['name'];
  $telephone = $_REQUEST['telephone'];
  $from = $_REQUEST['from'];
  $to = $_REQUEST['to'];
  $date = $_REQUEST['date'];
  $returndate = $_REQUEST['returndate'];
  $people = $_REQUEST['people'];
  $return = $_REQUEST['return'];
  $myemail = $_REQUEST['myemail'];
  
  include_once('includes/config.php');
  
  $settingsSql = mysql_query("SELECT * FROM transfers_in WHERE location='$to' AND no_passengers='$people'");
  $settings        = mysql_fetch_assoc($settingsSql);
  
  echo "From: ".$from." To: ".$settings['location']."&lt;br /&gt;";
  echo "Number of passengers: ".$settings['no_passengers']."&lt;br /&gt;";
  
  ini_set('date.timezone', 'Europe/Madrid');
  $now = date("H:i");
  
  $cutoff = "06:00";
  $higherthan = "22:00";
  
  echo "Time cost: ".$settings['price']." euros&lt;br /&gt;&lt;hr /&gt;Total: ";
  
  
  
      function timeCost() {
  
          $to = $_REQUEST['to'];
          $people = $_REQUEST['people'];
          $return = $_REQUEST['return'];
  
          include_once('includes/config.php');
  
          $settingsSql = mysql_query("SELECT * FROM transfers_in WHERE location='$to' AND no_passengers='$people'");
          $settings        = mysql_fetch_assoc($settingsSql);
  
          //echo $return;
  
          if ($return == "No"){
              if ((strtotime($now) &lt; strtotime($cutoff)) || (strtotime($now) &gt; strtotime($higherthan))){
                  echo number_format($settings['price']) + 1.40;
              } else {
                  echo number_format($settings['price']) + 0.00;
              }
          } elseif ($return == "Yes") {
              if ((strtotime($now) &lt; strtotime($cutoff)) || (strtotime($now) &gt; strtotime($higherthan))){
                  echo number_format($settings['price']) * 2 + 1.40;
              } else {
                  echo number_format($settings['price']) * 2 + 0.00;
              }
          }
  
          echo " in euros&lt;br /&gt;&lt;br /&gt;";   
      }
  
      echo timeCost();
  
  
  } else { ?&gt;
  
  &lt;form method="POST" action="thank-you.php" name="chooseDateForm" id="chooseDateForm"&gt;
              &lt;label&gt;Name:&lt;/label&gt;
              &lt;input type="text" value="" name="name" /&gt;
  
              &lt;label&gt;Telephone:&lt;/label&gt;
              &lt;input type="text" value="" name="telephone" /&gt;
  
              &lt;label&gt;Email:&lt;/label&gt;
              &lt;input type="text" value="" name="myemail" /&gt;
  
              &lt;label&gt;From:&lt;/label&gt;
              &lt;select name="from"&gt;
                  &lt;option selected="selected"&gt;Malaga&lt;/option&gt;
              &lt;/select&gt;
              &lt;div class="clr"&gt;&lt;/div&gt;
  
              &lt;label&gt;To:&lt;/label&gt;
              &lt;select name="to"&gt;
  
  &lt;?php foreach ($data as $place =&gt; $price){
      echo "&lt;option&gt;{$place}&lt;/option&gt;\n";
  }
  echo '&lt;/select&gt;
              &lt;div class="clr"&gt;&lt;/div&gt;
  
              &lt;label&gt;Date:&lt;/label&gt;
              &lt;input type="text" value="dd/mm/yyyy" id="date" name="date" class="date-pick" /&gt;
              &lt;span id="calendar"&gt;&lt;/span&gt;
  
              &lt;div id="return-journey"&gt;
                  &lt;label&gt;Return Date:&lt;/label&gt;
                  &lt;input type="text" value="dd/mm/yyyy" id="returndate" name="returndate" class="date-pick" /&gt;
                  &lt;span id="calendar"&gt;&lt;/span&gt;
              &lt;/div&gt;
  
              &lt;label&gt;Number of people:&lt;/label&gt;
              &lt;select id="people" name="people"&gt;
                  &lt;option value="4"&gt;4&lt;/option&gt;
                  &lt;option value="6"&gt;6&lt;/option&gt;
                  &lt;option value="8"&gt;8&lt;/option&gt;
              &lt;/select&gt;
              &lt;div class="clr"&gt;&lt;/div&gt;
  
              &lt;div id="return"&gt;
                  &lt;label&gt;Is this a return&lt;br /&gt;journey?&lt;/label&gt;
                  &lt;div class="clr"&gt;&lt;/div&gt;
                  &lt;div id="radio-buttons"&gt;
                      &lt;input type="radio" name="return" value="Yes" class="radio returning" /&gt;Yes&lt;br /&gt;
                      &lt;input type="radio" name="return" value="No" class="radio" checked /&gt;No
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="clr"&gt;&lt;/div&gt;
  
              &lt;input type="submit" name="submit" class="fauxButton" /&gt;            
  
          &lt;/form&gt;';
  }
  ?&gt;
  </code></pre>