Forums

Using session to data and php

Tiw 26 Mar, 2012
Hi!

I'm having some problem getting the data from my forms into my php code after using sessoin to data.

I have two text fields in the first form, they are named "kvm" and "rum" and then a submit button.

when I hit the submit button it sends the user to a second form with the same text fields "kvm" and "rum", these fields work fine and gets the same data that was sent from the first field.

the problem is that on the second page I also have a php code that does some calculations, but "kvm" and "rum" doesnt load in the php code. I've tried the php code in the first form and it works fine there.

so how do I get the data from the session into the php code? I can emagine the problem is in the _POST

The code looks like this:

<?php
$kvm = $_POST['kvm'];
$rum = $_POST['rum'];
$avdrag = $kvm*58;
$eta = 250;
$red = $avdrag/2;
$pris = $avdrag + $eta;
$rutpris = $avdrag/2 + $eta;
echo "<span style='font-size: medium;'>";
echo "<strong>Ditt Pris". $kvm;
echo " kvm</strong><br>";
echo "<br>Arbetskostnad (Avdragsgill)   = ". $avdrag;
echo " kr";
echo "<br>Etablering (Ej Avdragsgill)      = ". $eta;
echo " kr";
echo "<br>Summa före skattereduktion  = ". $pris;
echo " kr";
echo "<br><br>Skattereduktion = -". $red;
echo " kr";
echo "</span><br><br><strong><span style='font-size: medium; color: #ff0000;'>Ditt pris: ". $rutpris;
echo " kr</strong></span><br><br><br>";
?>
Tiw 26 Mar, 2012
Solved the problem.

I should use $form->data instead of $_POST
GreyHead 26 Mar, 2012
Hi Tiw,

Yes, that's correct, ChronoForms v4 puts almost everything into the $form->data array. If in doubt use a Debugger action to print it out and see what is in there.

Bob
This topic is locked and no more replies can be posted.