Forums

User registration with own form

Windwachter 11 Mar, 2012
Hey guys,

I am new to Chronoforms V4. I succeeded in making a custom loginform with Chronoforms, but now I face a much more complex job, as described below:

I want to offer people to registrate on the website with a registration form I made. They have to fill in quite some personal information, add a file and their username and password to use as well. When they submit the form they have to response on the email verification, otherwise the account will be deleted after 2 days or so. When successfully registrated the user can login to the website and adapt their profile or even delete it.
These profiles should be saved in my mysql database, in a new table: rzvl_users_people for example.

When administrators login to the front of the website, they should see a list of all people who registrated themselves, the people saved in rzvl_users_people. Just with a bit of information about the persons, when they want to see more information they should click on the person to get the full profile.

The attached file shows my setup for the events of the registration part. I am doubting if I should use the joomla registration event or a custom recorder because I want to save the users in a differtent database table then joomla does.

Does anyone have suggestions?
Will there be a Chrono Book for V4? I think that would really help me building it... so I don't have to ask all those things on this forum.

Thanks in advance!
GreyHead 12 Mar, 2012
Hi WindWatcher,

Sorry there is no book for CFv4 and, at present, no time to write one.

What have you chose to set up a parallel registration process? You'll be duplicating a lot of the code that Joomla! already provides and making yourself a lot of work by doing that. If you have Joomla! 2.5 then there is enough flexibility in the user groups to do what you need.

The rest you can do eaily enough with ChronoForms and ChronoConnectivity (for the listings).

Bob
Windwachter 12 Mar, 2012
Thnx for you reply GreyHead!

What I have in mind is as follows:
The people who will registrate themselves with use of the form attached to this post, their information should be saved in a new database table, not the standard joomla jos_users. This because of lots of extra information which should be stored in that table as well.

Or is the best way to just add new columns in jos_users to store the extra information of my new registrations?

I have very little knowledge of databases, that's why I asked for the book.
GreyHead 12 Mar, 2012
Hi Windwachter,

The best way is to keep the Joomla! Users information in the Joomla! User table (name, ID, email, etc.) and to use a second table for the new info but to link the two using the User ID; if you create the new table using the ChronoForms Create Table icon this column will automatically be added.

I suggest that you look at this document it was written for ChronoForms v3 but all the ideas extend fairly simply to ChronoFroms v4 (ask if there are bits that aren't clear).

Bob
Windwachter 14 Mar, 2012
Hey Bob,

Thanks for the tip! I downloaded the document and tried some stuff the last two days. Unfortunately I am not feeling the flow of it. It's because of my lack of experience with this stuff. Besides that, I was wondering, isn't the biggest part of the code described in the document automated in V4, partly with ChronoConnectivity?

You mensioned that the User ID is automatically added in the linked second table, the column therefor is cf_uid? This column is encrypted in the second table. Is this column the same as in the table jos_users column ID, which is not encrypted?

Is it nescessary to link the two tables with the use of the column PARAMS in the jos_users table? If I don't need to use the PARAMS column to link the two tables, quite some code in the document is superfluous right?


I am sorry to ask such questions, I think for you guys it's really the basic stuff, but perhaps you can point me to some tutorials which are more understandable for novice users? The document you mensioned was hard to follow for me because of the different versions of Chronoforms..
GreyHead 14 Mar, 2012
Hi Windwachter,

isn't the biggest part of the code described in the document automated in V4, partly with ChronoConnectivity?

No, I'm afraid not.

the column therefor is cf_uid?

No, the cf_uid column is a random string; the uid is in plaintext as cf_user_id.

Is it nescessary to link the two tables with the use of the column PARAMS in the jos_users table?

No, the Params are an alternative way of storing simple data in the jos_Users table, they have nothing to do with linking tables.

perhaps you can point me to some tutorials which are more understandable for novice users?

If there were any then I would :-(
Bob
Windwachter 15 Mar, 2012
Hey GreyHead,

Yesterday evening I again worked through the whole tutorial (chronoapplication-extended-user-information). I now understand it much better.

I was a bit confused about the linked tables because Joomla user_id wasn't the same as the cf_user_id. I thought these would automatically be the same. I searched on this forum and with a code of Max I get it done to copy the Joomla user_id to cf_user_id:
<?php
	$form->data['cf_user_id'] = $form->data['_PLUGINS_']['joomla_registration']['id'];
?>


This and the DB save (which is build in in Chronoforms) works fine until I began following the tutorial.
The DB save is turned off now and a custom DB save has to be made. What's not clear about this is if I have to build the table first for the form to save data to, or is it build automatically by the custom DB save?
Either ways, it is not building the table automatically, and when I build it using Chronoforms, the custom DB save isn't saving the data in it (table jos_users_student_cv_data). The Joomla user registration works fine and creates a new user in jos_users.
Max_admin 15 Mar, 2012
Hi Windwachter,

I understand that you need to store the extra user data into another table and link it to the user table, correct ?

I see that you have done 90% of it, you have managed to add the created user id to the cf_user_id field of the custom table, now why do you need a custom db saving action ? the core one should work fine, and it should add any form data to the new custom table, what's missing now ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Windwachter 15 Mar, 2012
Hey Max!

Thanks for you reply! Indeed, I need to store extra user information in another linked table. Because of my lack op experience I bought the ChronoApplication How-to doc: Build an extended User information form.
I followed the complete tutorial and therefore I had to take out the the cf_id field name. That's the standard Primary key with auto_increment. To make the cf_user_id the Primary key with the same value as the Joomla user_id (without auto_increment) there has to be made a new method to store the data. As explained in the tutorial: the standard Joomla! store() method won't work with our cf_user_id as the primary key (it expects an autoincrementing key instead).

Perhaps this is now possible in Chronoforms V4 or can I let the cf_id field be there in my table as Primary key?

Thanks in advance!
Max_admin 17 Mar, 2012
Hi Windwachter,

V4 makes this stuff much easier, your extra details table should have a primary key auto incremented, so please add the cf_id back, and make it the only primary key instead, once you do this, and according to what you have, the 2 tables should be in sync(jos_users and the extra table), what do you need to do now ? display the data from associated records or something else ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Windwachter 19 Mar, 2012
Thank you Max!

The form is working now and saving data to jos_users and jos_users_student_cv_data!

Next thing is to build an userprofile when that person is logged in. Here the users should be able to update their profile. With use of the tutorial, I managed to recall the saved data, except the data from gender. It's a radiobox. With my test user I saved the value 'female'. But when I look at her profile neither the radio 'male' or 'female' selected. I can't figure out what's woring with this one.

Second part that is not working is the update button of this userprofile form. It should update the information about the user, but there is nothing happening when I push that button.

I don't know if it is allowed to post the codework of these two problems I have.. because they are from the tutorial I bought at greyhead.net. Let me know if I can post them or have to send it personal to you!
Windwachter 19 Mar, 2012
I am working on getting a radio box checked, male or female.
Correct me if I'm wrong, with the code below I select all the information from my database table of one record.
$query = "
	SELECT *
	FROM `#__users_student_cv_data`
	WHERE `cf_user_id` = ".$user->id." ;
	";

The next 2 code lines are to load all the information of the selected record. The if is to check if 'woonplaats' got a value in my database table for that record. Is this necessary code I have to program for every column to retrieve all the information?

	$db->setQuery($query);
	$data = $db->loadObject();
		if ( !count($data) ) {
			$data->woonplaats = '';
		}

The last code is to insert the value from the database woonplaats column into the input field.
value="<?php echo $data->woonplaats; ?>"


Till now, everything works, but not for my radio box.

For my gender radio box, the value is already loaded?? so $gender already had its value loaded with the last code:
$db->setQuery($query);
	$data = $db->loadObject();

Then, when the value is 'male' the following code should check the radiobox of male?:
<input value="man" title="" class="radio" id="gender1" name="gender"
				type="radio" <?php if($gender=='male'){?>checked="checked"<? }?> />


But, this is not working... Did I forgot to load the $gender value? If yes, how do I have to load it?
GreyHead 20 Mar, 2012
Hi Windwacther,

This looks like hard work. If you use a ChronoForms DB Record Loader action in the ON Load event it will create the MySQL query for you and the Show HTML action will st the data values in the form (including checkboxes).

You don't say here where the value of $gender is coming from? Is it a part of the $d object from your table or have you saved it separately as a parameter in the User object? (Either method is OK.)

Bob

PS The reason for using the 'user id' as the primary key on the user data table is to prevent duplicate resords, neither ChrnoForms nor Joomla! require the primary key to be autoincremented; just that it ie unique and numeric to the User iD works well.
Windwachter 20 Mar, 2012
Hey GreyHead,

I am really beginning to feel like I'm the ultra noob.. With the custom code from your tutorial recalling the data worked almost totally.
Now with the DB record load nothing works. I read the tutorial of Max for this, but I don't wanna load a record based on the token he uses. The user first has to be logged in, then they can update their profile data.
I think I am missing the connection of the logged in user id with the DB record loader which has to search the record with the corresponding user id, in 2 tables: jos_users and jos_users_student_cv_data.

With the debug function I see the following:
SELECT * FROM `rzvl_users_student_cv_data` AS `RzvlUsersStudentCvData` WHERE `cf_user_id` = ".$user->id."

Comparing with the code from your tutorial I used first, I think the AS `RzvlUsersStudentCvData` is not needed, or what does it exactly and I put in a custom WHERE code in the Advanced tab, as the code shows..

Nothing works, I tried to put the user_id in a hidden field, but it doesn't work. On the forum for someone it worked to put in the users id in a header box, with the curl: {cf_user_id}. Doesn't work for me either (my Curly replacer is ON)

I am working on this now for 2 weeks or so, but little progress has been made. I am already reading php books to have the basic skills.. but I am getting desperate now.😟
GreyHead 21 Mar, 2012
Hi Windwachter,

The 'token' that Max refers to is just an way to identify the record you want to load.

If you want to load data for the current user there are two steps to it.

First, drag a Custom code action into the event and move it before the DB Record Loader action. In this put this code
<?php
$user =&Jfactory::getUser();
$form->data['user_id'] = $user->id;
?>
This will add the current user ID to the form data.

Second, open the DB Record Loader and (a) put the column name with the User ID in it into the DB Field box and (b) add user_id into the Request param box. Set the table name and any other settings you need here.

Bob
Windwachter 30 Mar, 2012
GreyHead, first of all, I'm gonna buy you a drink this weekend!
Thanks for your effort! The loading of the user's information is working quite a time now.

But now I'm facing some other problems with the userprofile updateform:

I took some code out of the tutorial to check if the name, username and email are unique.
I read this post: http://www.chronoengine.com/forums.html?cont=posts&f=26&t=26027 and I adapted the code as you mentioned over there. But it is still not working: I can make non unique name, username and email values.

Second question: The user should be able to upload a new file and delete the old file.
When a new file is choosen, the old one should be deleted when the submit button is pressed. If there is no new file choosen, the old one can stay on the server. Is this possible in Chronoform?[attachment=0]Knipsel2.PNG[/attachment]
This topic is locked and no more replies can be posted.