Check up input show warning if the same input exist allready

Radjinn 14 Mar, 2013
Hi Chronoengine community,
i hope you can help me out whit this:

I build a Form where the user can enter his name, surename,date, and a code. Now it is verry important for me that the Code imput get checked up! How i can handel this!

The code is a 6 digits long combination that i created and send the user whit email, so i know what the code is, can i let chronoforms check up a list of codes in a maybe xml file from the server and only if the code exist the users form entry shoud been uploaded. And if the code is used and saved one time there shoud be a message like "the code is used allready" and the entry shoud not ben saved or uploaded to the database!

Is there a option where i can handel this?
GreyHead 14 Mar, 2013
Hi Radjiin,

The easy way to do this is to check with PHP in a Custom Serverside validation action in the form On Submit event.

Another way is to use Ajax to check the code in the form.

Bob
Radjinn 14 Mar, 2013
thank you for your fast answer, but can you explain me what to whrite in to the php code section! I have no clue, to say "if the answer is not 1111 then the answer is wrong" :-) i am not a good programmer, i am just a designer how try to handel this!

So i get the custom serverside validation in to my on submit area and now what?
GreyHead 14 Mar, 2013
Hi Radjinn,

Then you will need help from someone who can write the custom code that you need.

Bob
Radjinn 14 Mar, 2013
ok i tryed this it works but only whit one code, if i put multiple codes like here:

<?php
if ( strpos($form->data['code'], "1111","2222","3333") === false ) {
$form->validation_errors['code'] = "Your code is wrong!";
return false;
}
?>

i get this error message, he save everything but shows this message, dont get it!

Warning: strpos() expects at most 3 parameters, 4 given in /XXXXX/XXXXXX/XXXXX/XXXXXX/administrator/components/com_chronoforms/form_actions/custom_serverside_validation/custom_serverside_validation.php(19) : eval()'d code on line 2
GreyHead 14 Mar, 2013
Hi Radjiin,

I have no idea what that code is supposed to do but the warning message is pretty clear, strpos() only takes three parameters and you have added four.

Bob
Radjinn 14 Mar, 2013
GreyHead just one step away from my goal if you coud help me out whit this.

Like i say before, i want that chronoforms check a code or call it password before he accept the hole form. I found a way to handel it whit "Custom Serverside Validation"
whit this code:
<?php
$password =& $form->data['password'];
if ( !isset($password) || !$password || $password != '3333' ) {
  $form->validation_errors['password'] = 'Please enter a valid password';
  return false;
}
?>


like you can see the password is "3333". what i just need now is how to put in more then one password possibility!
If i put a "," after the password like != "3333", "4444" ) the form give an error!

How i am possible to doe that?
Max_admin 15 Mar, 2013
if(!isset($password) || !$password || !in_array($password, array('3333', '4444', '5555'))) {


I hope that helps!🙂

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Radjinn 15 Mar, 2013
Thank you verrry much MAX!!! For you just a peace of cake, for me headcrashes :-)

Maybe you can afford just a little bit more an tell me how i can tell chronoforms to say:

If one of the codes "1111", "2222", "3333", is used allready give a warning message!

My Chronoforms layout locks out like this
Check up input show warning if the same input exist allready image 1

at result of checking the code i have set a database save, because i have a Menu on the website whit chronoforms connection lis, where every registered Codes can be seen, so the last step ist to forbit the system to save a code whitch is used allready!

Like this: Max is typing in the codesection the code 1111, the system checks the code, it is existing and free, so he save Max´s code whit his name. Dave types in 1111 to, the system checks and give out a warning "your code is used allready" and do not save it and return too the form!

Maybe again just a peace of cake but like i sayed i am not a programmer, but woud be so happy if someone coud help me out whit this!
Radjinn 15 Mar, 2013
Thanks Bob but really i am not trying to let do other my work, i read tons of your FAQ´s but i cant use them, just like the other question i got, Max just write how to do and i got it! But this FAQ you post i read it 10 time, tried to use it 10 times always whit syntax errors.

Like i sayed i am not a programmer, just try to get it work and if i do i will buy your license, i woud make also a donation if you or Max just write me the php code for this!

I mean before i go and hire a freelancer and pay him for this i can do it direcly to Chronoengine!

And your Faq tells me how i make a server validation, but not how i can check allready saved content from the database and give them a response! The server validation i got allready whit the code i postet in the picture, chrono checks the given codes and do a save or not, but how i say if code "1111" is saved allready do not save again. Because it saves every time when i type in a valid code. Or did i miss something?
Max_admin 17 Mar, 2013
Hi Radjiin,

simply drag a "DB record loader" action to the top of the "on success" event of the "Custom server side validation", then configure it to load the record with the password provided, and insert an "Event loop" in the "on record found" event so that it reloads the form if the record was found.

then configure it to load the record


Table name: your table where you save records.
Request param: the field name holding the password (code ?)
DB Field name: the table's column storing the passwords used.

Easy!🙂

Regards,
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.