• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to make this work???

How to make this work??? 14 years 7 months ago #8671

Hi,

I could need some assistance here. Im trying to make a registration form where the user has to fill in 2 unique fields. I use the basis of the unique registration number given in the documentation. But I want a second field to be used. Here is my code:
if(isset($_POST['form']['cardid']))
{
$validCodesCard = array('EEEE','FFFF','GGGG','HHHH');
$foundValidCard = false;
foreach($validCodesCard as $validCodeCard)
if( strtolower($validCodeCard) == strtolower($_POST['form']['cardid'])) $foundValidCard = true;
 
if(!$foundValidCard)
{
$invalidCard[]=RSresolveComponentName('cardid',$formId);
echo RSshowForm($formId, $_POST['form'], $invalidCard);
}
}
 
 
if(isset($_POST['form']['RegistrationCode']))
{
$validCodes = array('AAAA','BBBB','CCCC','DDDD');
$foundValid = false;
foreach($validCodes as $validCode)
if( strtolower($validCode) == strtolower($_POST['form']['RegistrationCode'])) $foundValid = true;
 
if(!$foundValid)
{
$invalid[]=RSresolveComponentName('RegistrationCode',$formId);
echo RSshowForm($formId, $_POST['form'], $invalid);
}
}
 
 
if (isset($_POST['form']['username']) AND !$invalid AND !$invalidCard)
{
$database =& JFactory::getDBO();
$fullname = $_POST['form']['fullname'];
$email = $_POST['form']['email'];
$username = $_POST['form']['username'];
$password = $_POST['form']['password'];
$database->setQuery("SELECT `id` FROM #__users WHERE `username`='".$username."'");
$database->query();
if ($database->getNumRows() > 0) die('This username is already taken. Please press back and try a different username.');
$database->setQuery("INSERT INTO #__users (`name`, `username`, `email`, `password`, `usertype`, `block`, `sendEmail`, `gid`, `registerDate`, `lastvisitDate`, `activation`, `params`) VALUES('".$fullname."', '".$username."', '".$email."', '".md5($password)."', '', 0, 0, 18, now(), now(), '', '')");
$database->query();
$userid = $database->insertid();
$database->setQuery("INSERT INTO #__core_acl_aro (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`) VALUES ('', 'users', '".$userid."', 0, '".$fullname."', 0)");
$database->query();
$aro_id = $database->insertid();
$database->setQuery("INSERT INTO #__core_acl_groups_aro_map (`group_id`,`section_value`,`aro_id`) VALUES ('18','','".$aro_id."')");
$database->query();
 
}
 
 

Hope that someone can help me out.

Thanks in advance.
Danny
Last Edit: 14 years 7 months ago by kessels1234.
The administrator has disabled public write access.

Re:How to make this work??? Unique Registration 14 years 7 months ago #8688

OK a littlebit further but not solved yet. I want to compare 2 fields (cardid and RegistrationCode) with the data in the arrays. My problem is that I can't seem to find the solution to put those values in the variable $invalid (don't know the right synthax. This is the code I have so far:
if(isset($_POST['form']['cardid']))
{
$validCodesCard = array('EEEE','FFFF','GGGG','HHHH');
$foundValidCard = false;
foreach($validCodesCard as $validCodeCard)
if( strtolower($validCodeCard) == strtolower($_POST['form']['cardid'])) $foundValidCard = true;
}
 
 
if(isset($_POST['form']['RegistrationCode']))
{
$validCodes = array('AAAA','BBBB','CCCC','DDDD');
$foundValid = false;
foreach($validCodes as $validCode)
if( strtolower($validCode) == strtolower($_POST['form']['RegistrationCode'])) $foundValid = true;
 
if(!$foundValid || !$foundValidCard)
{
$invalid[]=RSresolveComponentName('RegistrationCode',$formId);
 
echo RSshowForm($formId, $_POST['form'], $invalid);
}
}
 
 
if (isset($_POST['form']['username']) AND !$invalid)
{
$database =& JFactory::getDBO();
$fullname = $_POST['form']['fullname'];
$email = $_POST['form']['email'];
$username = $_POST['form']['username'];
$password = $_POST['form']['password'];
$database->setQuery("SELECT `id` FROM #__users WHERE `username`='".$username."'");
$database->query();
if ($database->getNumRows() > 0) die('This username is already taken. Please press back and try a different username.');
$database->setQuery("INSERT INTO #__users (`name`, `username`, `email`, `password`, `usertype`, `block`, `sendEmail`, `gid`, `registerDate`, `lastvisitDate`, `activation`, `params`) VALUES('".$fullname."', '".$username."', '".$email."', '".md5($password)."', '', 0, 0, 18, now(), now(), '', '')");
$database->query();
$userid = $database->insertid();
$database->setQuery("INSERT INTO #__core_acl_aro (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`) VALUES ('', 'users', '".$userid."', 0, '".$fullname."', 0)");
$database->query();
$aro_id = $database->insertid();
$database->setQuery("INSERT INTO #__core_acl_groups_aro_map (`group_id`,`section_value`,`aro_id`) VALUES ('18','','".$aro_id."')");
$database->query();
 
}

Again, I hope someone can take the time to help me out with this one.

Thanks
Danny
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!