Chrono register form

Rapdrei 26 Sep, 2014

i am new to chronoforms and i want to create a registration form for joomla with extended fields.
Using the joomla registration action for the default fields works fine but i run into an error when i want to save the additional fields in a other table.
My plan was to read the id of the joomla database entry from "_users" and write a entry with this id and my additional fields into my chronodb.
I also found the read database and write database action. The details on how to use this particular actions is the problem :?

Any help is apreciated

GreyHead 26 Sep, 2014
Hi Dennis,

Please see this FAQ for info on getting the User ID of a newly registered user. I think that the same code will work in CFv5.

Rapdrei 26 Sep, 2014
Hi calculus and GreyHead,

thank you very much for the help. I will digg a little bit deeper in the links you provided me! 🙂

Rapdrei 28 Sep, 2014
Hey there,

i decided to overcome my problem by a custom code solution which will be triggered after pressing the submit Button.
My php code basically creates a record in joomla_users and puts the additional information (newsletter, institute, affiliation_type..) into a seperate table.

The code is almost done. The only thing i dont know is how i can acess the value inside input fields i designed earlier. Lets say i added a field Username in the form editor. How can i get the Username the user added into the field after pressing submit?
would this work:
$username = $form->data['username'];

Heres is a part of my code so far:
$mysqli = new mysqli(constant(HOST), constant(USERNAME), constant(PASSWORD), constant(DBNAME));

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());

$insert_id = null;

/* create a prepared statement */
if ($joomla_users_stmt = $mysqli->prepare("INSERT IGNORE INTO $joomla_users (name, username, email, password, block, sendEmail, registerDate, lastvisitdate, resetcount, requirereset)
 VALUES (?, ?, ?, ?, 0, 1, ?, ?, 0, 0)")) {

    // just fetch the inputfields from the chronosform fields
    $name = $form->data['name'];
    $username = $form->data['username'];
    $email = $form->data['email'];
    $password = $form->data['password'];
    $regdate = getdate();
    $lastvisit = $regdate;

    //check if the email is not already used
    $result = mysqli_query($mysqli,"SELECT * FROM JOOMLA_USERS WHERE email = \"$email\"");
    $row = mysqli_fetch_array($result);
    $found = $row['email'];

    //if the query returns an empty string, the email is not already registered
    if(!$found == null)
        printf("Email already in use");

    //build md5 applied salted password with joomla helper
    $crypted_password = JUserHelper::hashPassword($password);

    /* bind parameters for markers */
    $joomla_users_stmt->bind_param("ssssss", $name, $username, $email, $crypted_password, $regdate, $lastvisit);

    /* execute query */

    $insert_id = $joomla_users_stmt->insert_id;

    /* bind result variables */

    /* fetch value */

    /* close statement */

if ($chrono_users_stmt = $mysqli->prepare("INSERT IGNORE INTO $chrono_users (id, newsletter, institute, affiliation_type, intend_to_use)
 VALUES (?, ?, ?, ?, ?)")) {

    //catch the additional tableinformation from chrono input fields
    $newsletter = $form->data['newsletter'];
    $institute = $form->data['institute'];
    $affil_type = $form->data['affiliation_type'];
    $intend_to_use = $form->data['intend_to_use'];

    $chrono_users_stmt->bind_param("ddsss", $insert_id, $newsletter, $institute, $affil_type, $intend_to_use);

    /* execute query */

    /* bind result variables */

    /* fetch value */

    /* close statement */

/* close connection */
GreyHead 29 Sep, 2014
Hi Rapdrei,

You can use $username = $form->data['username']; but it doesn't really do anything useful. Just use $form->data['username']

I would strongly recommend that you add to the Joomla! Users table using the methods that are provided in the Joomla! User Object rather than writing directly to the table.

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