Here is my scenario customer is given a unique code. During registration they must enter this code from a predefined list of codes in order to submit there registration to my website. IF the code is invalid they cannot register.
I found the following code referred to in various answers on the forums:
From the answers I found on the forum, I still don't know how to implement this and where to enter the code. I have some basic coding experience but I definitely am not a programmer.
I am assuming that I put it under serverside validation, but I can't figure out how to write the code.
Thanks
I found the following code referred to in various answers on the forums:
var f14 = new LiveValidation('f14');
f14.add( Validate.Inclusion, { within: [ 'cow' , 'pigeon', 'giraffe' ] } );
From the answers I found on the forum, I still don't know how to implement this and where to enter the code. I have some basic coding experience but I definitely am not a programmer.
I am assuming that I put it under serverside validation, but I can't figure out how to write the code.
Thanks
Hi bkhphoto,
LiveValidation is JavaScript mainly used in the browser for validation and layout management. Using this approach all of your valid codes would be exposed in the page HTML for anyone who cared to hunt around.
The better approach is to use PHP in the Serverside validation box. Here's an example of the code you might use there - this looks up some info in a database table.
Bob
LiveValidation is JavaScript mainly used in the browser for validation and layout management. Using this approach all of your valid codes would be exposed in the page HTML for anyone who cared to hunt around.
The better approach is to use PHP in the Serverside validation box. Here's an example of the code you might use there - this looks up some info in a database table.
Bob
Thanks That worked great.
I used the following code
I am using this on a registration form for a website using joomla registration plugin. Is there a way to pass the code and attach it in some way to the user, so that once used the code cannot be used again?
Thanks
I used the following code
<?php
$db =& JFactory::getDBO();
$text_5 = JRequest::getString('text_5', '', 'post');
$query = "
SELECT COUNT(`column0`)
FROM `jml_easytables_table_data_1`
WHERE `column0` = ".$db->Quote($text_5).";
";
$db->setQuery($query);
if ( !$db->loadResult() ) {
return "That is an invalid code please enter it again";
}
else {}
?>
I am using this on a registration form for a website using joomla registration plugin. Is there a way to pass the code and attach it in some way to the user, so that once used the code cannot be used again?
Thanks
Hi bkhphoto ,
I'd probably add a new table to associate the code with the user_id and add that to the check code. (There may be better ways like adding a user_id column to the code table.)
Bob
I'd probably add a new table to associate the code with the user_id and add that to the check code. (There may be better ways like adding a user_id column to the code table.)
Bob
Thanks for all of your help so far. This project is a slow one. Anyway to come back to this question. I am trying to combine two query's to do two different validations on one field. With two different tables. First table is a preset table containing validation codes. Second table is the table the form flows into at registration.
SO far the code correctly validates the code against the first table (jml_easytables_table_data_3), but I have been unable to get it to validate that the registration code against the second table (jml_chronoforms_Registration1). I have read several post on the forums, here is the code I have pieced together and cannot figure out what I am doing wrong. If I turn debug on I don't get any errors. I am trying to make it where the validation code can only be used once.
Here is my code.
This part of the above code works exactly as it should.
Thanks so much for your assistance.
SO far the code correctly validates the code against the first table (jml_easytables_table_data_3), but I have been unable to get it to validate that the registration code against the second table (jml_chronoforms_Registration1). I have read several post on the forums, here is the code I have pieced together and cannot figure out what I am doing wrong. If I turn debug on I don't get any errors. I am trying to make it where the validation code can only be used once.
Here is my code.
<?php
$text_5 = JRequest::getVar('text_5', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT count(*)
FROM `jml_chronoforms_Registration1`
WHERE `text_5` = ".$db->Quote($text_5)." ;
";
$db->setQuery($query);
if ( $db->loadResult()) {
return "That code has already been used, please try again";
}
$db =& JFactory::getDBO();
$text_5 = JRequest::getString('text_5', '', 'post');
$query = "
SELECT COUNT(`column0`)
FROM `jml_easytables_table_data_3`
WHERE `column0` = ".$db->Quote($text_5).";
";
$db->setQuery($query);
if ( !$db->loadResult() ) {
return "That is an invalid code please enter it again.";
}
else {}
?>
This part of the above code works exactly as it should.
$db =& JFactory::getDBO();
$text_5 = JRequest::getString('text_5', '', 'post');
$query = "
SELECT COUNT(`column0`)
FROM `jml_easytables_table_data_3`
WHERE `column0` = ".$db->Quote($text_5).";
";
$db->setQuery($query);
if ( !$db->loadResult() ) {
return "That is an invalid book code please enter it again";
}
else {}
Thanks so much for your assistance.
Ok This is now fixed I figured out my mistakes. Here is the corrected code.
<?php
$db =& JFactory::getDBO();
$text_5 = JRequest::getVar('text_5', '', 'post');
$query = "
SELECT count(*)
FROM `jml_chronoforms_Registration1`
WHERE `text_5` = ".$db->Quote($text_5).";
";
$db->setQuery($query);
if ( $db->loadResult()) {
return "That code has already been used, please try again.";
}
$db =& JFactory::getDBO();
$text_5 = JRequest::getString('text_5', '', 'post');
$query = "
SELECT COUNT(`column0`)
FROM `jml_easytables_table_data_3`
WHERE `column0` = ".$db->Quote($text_5).";
";
$db->setQuery($query);
if ( !$db->loadResult() ) {
return "That is an invalid code please enter it again";
}
else {}
?>
This topic is locked and no more replies can be posted.