[Solved] DB clone record

dec13els 16 Jan, 2011
Hi all,

i'm new french user here, i have a problem when i tries to use the Grey Head tutorial "ChronoForms saving to a database table" and some tips from the 1.3 ebook.

i need to work with some variable, and update her in the DB before use ChronoConnectivity.

my data are clone in the DB with a (cf_id +1), the first record are good (with my variable worked ) and the second is from the original form


FR :
Bonjour, j'essaye de mettre en place le tutoriel de Grey Head "ChronoForms saving to a database table"

Mes données du formulaire s'enregistre bien, j'arrive a retravailler mes variables mais lorsque je lance le formulaire, mes données sont doublées. le premier enregistrement est issu du formulaire d'origine, et l'autre est une copie avec mes variables retravaillés.

the on submit before email code :
<?PHP
$user = $_POST['user'];
$ram = $_POST['ram'];
$cpu = $_POST['cpu'];
$cm = $_POST['cm'];
$cores = $_POST['cores'];
$os = $_POST['os'];

$min3 = $_POST['min'];
$min2 = substr_replace("00",$min3, -strlen($min3));

$sec3 = $_POST['sec'];
$sec2 = substr_replace("00",$sec3, -strlen($sec3));

$bench3 = $_POST['bench'];
$bench2 = substr_replace("0000",$bench3, -strlen($bench3));

$oc = $_POST['oc'];
$fcpu = $_POST['fcpu'];

if ($oc == 0):
$color = "#006400"; /*vert*/
elseif ($fcpu > 4):
  $color = "#B22222"; /*rouge*/
else:
  $color = "#FF8C00"; /*orange*/
endif;

$data = array();
$data['user'] = $user;
$data['fcpu'] = $fcpu;
$data['min'] = $min2;
$data['sec'] = $sec2;
$data['oc'] = $co;
$data['bench'] = $bench2;
$data['ram'] = $ram;
$data['cpu'] = $cpu;
$data['cm'] = $cm;
$data['cores'] = $cores;
$data['os'] = $os;
$data['color'] = $color;
$record =& JTable::getInstance("chronoforms_benchwell_01", "Table");
$record->bind($data);
$record->store();
?>


Can you help me ?
Thanks


Best Regards
dec13els 16 Jan, 2011
a screen of the Connectivity result
GreyHead 16 Jan, 2011
Salut dec13els,

I think that you probably have the DB Connection enabled as well as the custom save in the OnSubmit Before Email box.

You don't need both - it will give you a double save. I suggest that you comment out this code in the OnSubmit Before box and see if that fixes the problem.
/*
$data = array();
$data['user'] = $user;
$data['fcpu'] = $fcpu;
$data['min'] = $min2;
$data['sec'] = $sec2;
$data['oc'] = $co;
$data['bench'] = $bench2;
$data['ram'] = $ram;
$data['cpu'] = $cpu;
$data['cm'] = $cm;
$data['cores'] = $cores;
$data['os'] = $os;
$data['color'] = $color;
$record =& JTable::getInstance("chronoforms_benchwell_01", "Table");
$record->bind($data);
$record->store();
*/
dec13els 16 Jan, 2011
Thanks for your help GreyHead ! 😀

when the code are comment, the DB record the original form and does not display the values i want.

( the reworked variable : min, sec, bench )

i have the same problem with the "on submit after" : double records

when i open the table, the first cf_id ( ex:10 ) are from the good record issu, the original record have a cf_id +1

Debug info after submit the form : ( witout the php code comment )

   1. Form passed first SPAM check OK
   2. Form passed the submissions limit (if enabled) OK
   3. Form passed the Image verification (if enabled) OK
   4. Form passed the server side validation (if enabled) OK
   5. $_POST Array: Array ( [user] => Roch [fcpu] => 2.66 [min] => 4 [sec] => 1 [oc] => 1 [bench] => 455 [ram] => 12 [cpu] => i7 920 [cm] => Asus Rampage Ext 3 [cores] => 4 [os] => XP [button_52] => Envoyer [3f199d17e77a0635fd8b347e58c89a03] => 1 [1cf1] => a61160f00b7c5b03f1a1f237485e6a6d [chronoformname] => Benchwell_01 )
   6. $_FILES Array: Array ( )
   7. Form passed the plugins step (if enabled) OK
   8. Debug End
dec13els 17 Jan, 2011
I tried with the plugin multipage, but without success.. :?

Mother + child 1 for the original data + child 2 for my reworked data with php and submit button.
GreyHead 17 Jan, 2011
Hi dec13els,

You need to comment out the code I suggested; and edit the remaining code to add the values to the $_POST array using JRequest::setVar() like this:
if ($oc == 0):
  $color = "#006400"; /*vert*/
elseif ($fcpu > 4):
  $color = "#B22222"; /*rouge*/
else:
  $color = "#FF8C00"; /*orange*/
endif;
JRequest::setVar('color', $color);

Then set the DB Connection "Saving Data/Emails order" setting back to 'After Email'.

Bob
dec13els 17 Jan, 2011
It works !

Many thanks Bob, i pay you a big pint of beer 😀

i can work some variable now 8)
This topic is locked and no more replies can be posted.