Beste mensen,

Ik heb een script.. Alles werkt perfect en het doorsturen via dompdf lukt heel goed.
Alleen de uitvoering van mijn berekening kan niet mee doorgestuurd worden. (echo $answer)
Het rare is echter dat wanneer ik bvb $total gebruik, het wel mee doorgestuurd wordt maar dat het resultaat echter 0 is dus ik veronderstel dat het script niet uitgevoerd wordt.
Alles werkt perfect alleen de uitkomst van mijn berekening kan ik niet mee doorsturen.


Hieronder mijn script..
[code]
<?php
$sympathisant=151.25;
$brons=25;
$perssymp=151.25;
$persbrons=25;

$total=0;

if(isset($_POST['sympathisant']) && $_POST['sympathisant']=='1')
{
$answer = $sympathisant ;
}

if(isset($_POST['brons']) && $_POST['brons']=='1')
{
$answer =$brons;
}
if(isset($_POST['perssymp']))
{
$num=(int)$_POST['perssymp']; // make sure only integers are accepted
if($num>0) // ignore negative values
{
$answer=$total+($perssymp*$num);
}
}
if(isset($_POST['persbrons']))
{
$num=(int)$_POST['persbrons']; // make sure only integers are accepted
if($num>0) // ignore negative values
{
$answer=$total+($persbrons*$num);
}
}

echo "Total price is \$$answer\n";



if (!empty($_POST)) {

// Used for later to determine result
$success = $error = false;

// Object syntax looks better and is easier to use than arrays to me
$post = new stdClass;

// Usually there would be much more validation and filtering, but this
// will work for now.
foreach ($_POST as $key => $val)
$post->$key = trim(strip_tags($_POST[$key]));

// Check for blank fields
if (empty($post->name) OR empty($post->email))
$error = true;

else {

// Get this directory, to include other files from
$dir = dirname(__FILE__);

// Get the contents of the pdf into a variable for later
ob_start();
require_once($dir.'/pdf.php');
$pdf_html = ob_get_contents();
ob_end_clean();

// Load the dompdf files
require_once($dir.'/dompdf/dompdf_config.inc.php');

$dompdf = new DOMPDF(); // Create new instance of dompdf
$dompdf->load_html($pdf_html); // Load the html
$dompdf->render(); // Parse the html, convert to PDF
$pdf_content = $dompdf->output(); // Put contents of pdf into variable for later

// Get the contents of the HTML email into a variable for later
ob_start();
require_once($dir.'/html.php');
$html_message = ob_get_contents();
ob_end_clean();

// Load the SwiftMailer files
require_once($dir.'/swift/swift_required.php');

$mailer = new Swift_Mailer(new Swift_MailTransport()); // Create new instance of SwiftMailer

$message = Swift_Message::newInstance()
->setSubject('How To Create and Send An HTML Email w/ a PDF Attachment') // Message subject
->setTo(array($post->email => $post->name)) // Array of people to send to
->setFrom(array('[email protected]' => 'Eindejaarsconcert')) // From:
->setCc(array('[email protected]'))
->setBody($html_message, 'text/html') // Attach that HTML message from earlier
->attach(Swift_Attachment::newInstance($pdf_content, 'nettuts.pdf', 'application/pdf')); // Attach the generated PDF from earlier

// Send the email, and show user message
if ($mailer->send($message))
$success = true;
else
$error = true;

}

}

?>


<html>
<head>
</head>
<body>
<?php if ($success) { ?>
<div class="message success">
<h4>Congratulations! It worked! </h4>
</div>
<?php } elseif ($error) { ?>
<div class="message error">
<h4>Sorry, an error occurred. Try again!</h4>
</div>
<?php } ?>
<form id="pricecalculation" method="post" action="">
<table>
<tr>
<td><label for="name">Your Name:</label></td>
<td><input type="text" name="name" id="name" class="input" /></td>
<td><label for="email">Your Email:</label>
<td><input type="text" name="email" id="email" class="input" /></td>
<tr>
<td>Vip arrangement </td>
<td>
<select name="sympathisant" id="sympathisant">
<option value="viparrangement">Ja</option>
<option value="">Nee</option>
</select> </td>
</tr>

<tr>
<td>Hoeveel personen? </td>
<td><input id="hoeveelpersonen1"name="perssymp" id="perssymp" size="3"></td>
</tr>
</br>
<tr>

<tr>
<td>Ticket </td>
<td>
<select name="brons" id="brons">
<option value="Ticket">Ja</option>
<option value="">Nee</option>
</select> </td>
</tr>
</tr>
<tr>
<tr>
<td>Hoeveel personen? </td>
<td><input name="persbrons" id="hoeveelpersonen2" type="text" id="persbrons" size="3"></td>
</tr>
<tr>
<input name="totaal" type="text" id="totaal" name="totaal" value=<?php echo "$answer"; ?>>
</tr>
</table>

<input name="submit" type="submit" value="Calculate price"/>
</form>

</body>
</html>

Zet error reporting aan.

Reageren