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());
exit();
}
$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");
exit();
}
//build md5 applied salted password with joomla helper
jimport('joomla.user.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 */
$joomla_users_stmt->execute();
$insert_id = $joomla_users_stmt->insert_id;
/* bind result variables */
$joomla_users_stmt->bind_result($district);
/* fetch value */
$joomla_users_stmt->fetch();
/* close statement */
$joomla_users_stmt->close();
}
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 */
$chrono_users_stmt->execute();
/* bind result variables */
$chrono_users_stmt->bind_result($district);
/* fetch value */
$chrono_users_stmt->fetch();
/* close statement */
$chrono_users_stmt->close();
}
/* close connection */
$mysqli->close();
?>