Hello ChronoEngine community,
I want to save the data submitted with a form in
the tables of the extension Community Builder. The aim
is to be able to use CB's features for the users
registering to my site.
I am currently trying to insert PHP code with the
tab "code" of the wizard edit using SQL queries,and when i insert:
in the "Custom Code - Before Email(s)" it works.
Now i need to replace \'text\' by the variable, if it exists,
of my textfield (for example) to save the user's input into CB.
What is the variable I must use ?
Is there any other solution to get the same result ?
Thank you in advance for your wise answers
PH
I want to save the data submitted with a form in
the tables of the extension Community Builder. The aim
is to be able to use CB's features for the users
registering to my site.
I am currently trying to insert PHP code with the
tab "code" of the wizard edit using SQL queries,and when i insert:
<?php
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=base_afeid', 'root', '');
$bdd->exec('INSERT INTO aftdb_users(name)
VALUES(\'text\')');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
in the "Custom Code - Before Email(s)" it works.
Now i need to replace \'text\' by the variable, if it exists,
of my textfield (for example) to save the user's input into CB.
What is the variable I must use ?
Is there any other solution to get the same result ?
Thank you in advance for your wise answers
PH
Hi phDevelopment,
If you have a value for the primary key of the table (I assume that name isn't the primary key) then the ChronoForms DS Save action should work for you. I assume that PDO uses the same Joomla! DB class.
If you don't have the primary key then you can write a query using the $form->data array to get the form values e.g. $form->data['name']
Bpb
If you have a value for the primary key of the table (I assume that name isn't the primary key) then the ChronoForms DS Save action should work for you. I assume that PDO uses the same Joomla! DB class.
If you don't have the primary key then you can write a query using the $form->data array to get the form values e.g. $form->data['name']
Bpb
Thanks GreyHead,
My primary key is ID (int and auto-increment) so I don't have
to write it in the query (or I am mistaken). Also it works but
I need to know 'n' for VALUES(n) in the query, n being the data written
by the user in the form.
I assume you are talking about the Store Data tab,
but I don't get it: what am I supposed to put in the fields
Model ID, Save Under Model ID, and Parameters Fields ?
I also tried this:
in the same code as my first post with X being the field id I chose for my text field or the model id I put in the SD tab.
I also tried $form->data[model_id]->field_id, and with/without the \'\' . The results are no data added, or blank fields added to the table
My mistake is probably as obvious as the nose on my face but i'm a beginner in PHP and joomla! so I don't get it. Could you be more precise ?
Thank you.
My primary key is ID (int and auto-increment) so I don't have
to write it in the query (or I am mistaken). Also it works but
I need to know 'n' for VALUES(n) in the query, n being the data written
by the user in the form.
I assume you are talking about the Store Data tab,
but I don't get it: what am I supposed to put in the fields
Model ID, Save Under Model ID, and Parameters Fields ?
I also tried this:
$bdd->exec('INSERT INTO aftdb_users(name)
VALUES(\'$form->data[X]\');
in the same code as my first post with X being the field id I chose for my text field or the model id I put in the SD tab.
I also tried $form->data[model_id]->field_id, and with/without the \'\' . The results are no data added, or blank fields added to the table
My mistake is probably as obvious as the nose on my face but i'm a beginner in PHP and joomla! so I don't get it. Could you be more precise ?
Thank you.
Up, I really need this in my work placement for my 2nd year computer science HND.
I posted in CB's, Joomla's forums and others. The only answer is from here.
I also tried this:
in "Custom Code - Before Email(s) (Click to configure)" but it won't work.
I posted in CB's, Joomla's forums and others. The only answer is from here.
I also tried this:
<?php
$name=$form->data['texte']];
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=base_afeid', 'root', '');
$req = $bdd->prepare('INSERT INTO aftdb_users(name)
VALUES(:name)');
$req->execute(array(
'name' => $name,
));
?>
in "Custom Code - Before Email(s) (Click to configure)" but it won't work.
This topic is locked and no more replies can be posted.