Forums

Chronoform + mysql + php

tonythuan 08 Apr, 2009
Hi everybody !
I'm new here, i've used CHRONOFORM a few days ago. i have a problem , please help me !
- I have a table caculation (4 fields) : a (type : float ) , b(type:float), c( type:float),d(type : varchar)
the problem is : " c =a/b .
if c < 10 -> d= "good".
10 < c < 20 ->d= "bad"
c > 20 -> d="verybad".
i use CHRONOFORM to create a form to input data to my table caculation. i only input data for 2 fields :a and b.the data of c and d will be caculated automatically."

Please help me ! Be clearly please !
Max_admin 09 Apr, 2009
Hi tony,

you can use this

$newC = C calculation here;
JRequest::setVar("c", $newC);


put the code above in the onSubmit after email code box, set the Autogenerated code to run After email too and then go to the "Run order" tab and make sure the Auto generated run order is higher than the onsubmit!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
tonythuan 10 Apr, 2009
HI, i cannot understand. please show me clearly ! How i do it ? i think i have to create a procedure MySQL, but i cannot do this.
please help me !
GreyHead 10 Apr, 2009
Hi Tony,

You do **not** need a MySQL procedure for this.

1) add two hidden fields in your Form HTML for c & d
<input type='hidden' name='c' value='' />
<input type='hidden' name='d' value='' />


2) In the OnSubmit after code calculate the values:
<?php
$a = JRequest::getFloat('a', '', 'post');
$b = JRequest::getFloat('b', '', 'post');
$c = $a/$b;
JRequest::setVar('c', $c);
if ( $c < 10 ) {
  $d = "good";
} elseif ( $c > 20) {
  $d="verybad";
} else {
  $d = "bad";
}
JRequest::setVar('d', $d);
?>

Bob
tonythuan 10 Apr, 2009
I have created a form with chronoform such as your advice.
I pasted your code in onSubmit code - after sending email . is it true ?
when i entered the data , i saw the data of field c and field d on my table is empty .
Please help me .
GreyHead 10 Apr, 2009
Tony,

I guess that you have some de-bugging to do then.

Bob
tonythuan 11 Apr, 2009
Hi GreyHead !
I did this successfully . thank you very much to your advice .
GreyHead 11 Apr, 2009
Hi Tonythuan,

Well done - what fixed it?

Bob

PS Sorry we can't help every step of the way - it just isn't practical, and you get to learn more by having to work some of it out.
This topic is locked and no more replies can be posted.