Forums

How to validate in Joomla Registration Form

Tomophy 07 Apr, 2009
I made a Joomla registration form with ChronoForms and have a problem.😟

If entering a username that already exists, Joomla rejects it but ChronoForms sends an email as if the registration was successful.

How do I validate if entered items already exist or not before sending email ?🀨
Max_admin 07 Apr, 2009
Hi Tomophy,

set the plugin to work "before email", this is in the Plugin config page!

now, in your onsubmit before email code, use this code:


<?php
$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if($MyPlugins->cf_joomla_registration['errors']){
$MyForm->stoprunning = true;
$MyForm->formerrors = $MyPlugins->cf_joomla_registration['errors'];
$MyForm->showForm($MyForm->formrow->name, $posted);
}
?>



this will work ONLY with V3.1 RC4 or above!

cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Tomophy 14 Apr, 2009
Hi Max,

Thanks for your reply.

I don't find "before email" in the Plug-in config page in ChronoForms V3.1 RC4 . :?
GreyHead 14 Apr, 2009
Hi tomophy,

I think this is the setting Max means.

Bob
Tomophy 16 Apr, 2009
Hi Bob,

I got it πŸ€”
Thank you for your advice.πŸ˜€
kythin 11 May, 2009
I'm having this problem too, but the solution isn't working for me😟

I've got my custom rego form working for new registrations, it even auto-login's and kicks the user to the right restricted page as long as the username isn't already in use.

If the username is in use, it still acts like it works except it doesnt autologin (for obvious reasons) OR if I have the redirect url blank, it just displays a blank screen. I've tried adding the PHP code from the above posts to the server side validation as well as the form AND plugin 'before submit' code textboxes and it doesn't seem to be working. I'm running 3.1RC5 btw.

If I run the form in debug mode it says everything checks out OK, even though I know the username is in use.


EDIT: Okay I've figured it out, I need to have an email set up and have the form send an email for the fix above to work. If you don't have the form sending an email on submission, it appears that the username in use validation doesn't run or doesn't return the right result.
GreyHead 11 May, 2009
Hi kythin,

That makes sense - the OnSubmit Before code only runs if email is enabled. OnSubmit After will always run.

Bob
ranail 09 Jun, 2009
I used this code and it stops the processing and redisplays the form, but the form data is empty.

<?php
global $post;
$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if($MyPlugins->cf_cb_registration['errors']){
$MyForm->stoprunning = true;
$MyForm->formerrors = $MyPlugins->cf_cb_registration['errors'];
$MyForm->showForm($MyForm->formrow->name, $post);
}
?>

I would expect the $post to bring back the values.
I am using CB and I saw that the cb_registratin.php file used $post
so I tried that and also added global $post and still nothing...

Any ideas?

Joomla 1.5.8
Chronoforms 3.1 RC4.11
AEC 0.12.6RC2p
JCE com:1.5.1 plugin:1.5.2
NOIXACL 2.0.5 beta
CB 1.2 RC4

PHP 5.29
MySQL 5.1.30
GreyHead 10 Jun, 2009
Hi ranail,

Where are you running this code?

$post is used internally by ChronoForms to hold the $_POST array values. It should be available to you, but it will depend on where you run the code.

Bob
ranail 10 Jun, 2009
On Submit code - before sending email:

I tried $posted as Max listed then tried $post not know which might be available.
Both did not work.

I upgraded to the new 5.1 and It has some options to "Try to publish" available fields.
And it comes up with username and password on initial entry but nothing for failed save when dups are found for email or username.

thanks,
Rusty
ranail 11 Jun, 2009
I have read several other forum posts about forms not republishing data on errors.

I have "republish" set to "Try to Republish"
I have "validation" set to Yes

I am trying to get the form to republish data when form entry error found on submit.

Name is required
username must be unique
email must be unique

all these cause the form to redisplay with empty fields.

I put this code in as Max suggested.

<?php
$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if($MyPlugins->cf_cb_registration['errors']){
$MyForm->stoprunning = true;
$MyForm->formerrors = $MyPlugins->cf_cb_registration['errors'];
}
?>


He had an additional line $MyForm->showform.... but that was causeing the form to display twice so I took it out.

Without any of this code, the form disappears like all is ok, but nothing happens.

What else needs to be done to bring the form data back?
GreyHead 13 Jun, 2009
Hi ranail,

I'm not quite sure what you are doing here.

If you want to add server-side validation for these fields then you can add some code in the Server-side validation box on the Validation tab and enable the validation there. This should re-display the form with the current values.

I don't see that Max's code is useful or helpful here.

Bob

PS For the validations you list - using ChronoForms built-in client side validation is probably easier.
Max_admin 15 Jun, 2009
Hi ranail,

the code below works fine when I have republish enabled in a new form with one field only in RC5.1


<?php
$MyForm =& CFChronoForm::getInstance();
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if(1){
$MyForm->stoprunning = true;
$MyForm->formerrors = 'ddddd';
}
?>


Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vdlkris 16 Jun, 2009
Hi ,

I also have the same problem and I tested it serval times. I read the instructions of max and did what I need to do. But the problem didn't solved.

So when I register by the site and use the same username and email after push the button to register I don't getting errors that the email and username is already existing. I get the redirect to my thank you page. I get the mail that is installed and enable by chronoforms, but no email from the joomla registration.

I don't know where the problem is ?

Thanks to help guys,

Kris
GreyHead 17 Jun, 2009
Hi vdlkris,

In the last few days there has been another thread here where I published a beta version of the Joomla Registration Plugin with more features that handles some of these problems.

Bob
Max_admin 22 Jun, 2009
Hi Kris,

Please show me a screenshot for the code used at your onSubmit box and make sure you have RC5.1

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.