Validate multiple possibilites

coachsutton 14 May, 2009
I am trying to use the server-side validation in chrononforms to ensure that the "access code" entered equals 1 of multiple possibilities. Then, based on what access code they enter, re-direct them to specific urls based on the access code entered. I know it is possible, just wondering if anyone has some advice??

My access code is going into field name regcode_1 . If the access code doesn't match, I want it to just display my "You have entered an invalid access code, please check your code and try again."

Thanks for any help.

JS
Max_admin 15 May, 2009
Hi coachsutton,


if(JRequest::getVar('regcode_1') != 'DAASDSADSAFDSREWDFSADF'){
return "You have entered an invalid access code, please check your code and try again.";
}


Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
coachsutton 15 May, 2009
Thanks Max, a few more questions...

In this code, how do you tell it to check if it matches MULTIPLE possibilities. Ex. access1, access2, and access3 are all valid codes. (I guess I don't know how to separate multiple values in this code)

Second question, once that works, how do I redirect to different pages based on the access code entereD?(currently all "validated" traffic goes to the re-direct URL set in Chronoforms)

Thanks.
Max_admin 18 May, 2009
Hi,

below is a multi check
    if((JRequest::getVar('regcode_1') != 'REWDFSADF')&&(JRequest::getVar('regcode_1') != '2REWDFSADF')&&(JRequest::getVar('regcode_1') != '3REWDFSADF')){
    return "You have entered an invalid access code, please check your code and try again.";
    }


you can use almost the same code with few changes in the onsubmit box to different redirection:


    if(JRequest::getVar('regcode_1') != 'DAASDSADSAFDSREWDFSADF'){
    $MyForm->setFormData('redirecturl', 'http://something here');
    }
if(JRequest::getVar('regcode_1') != 'SADF'){
    $MyForm->setFormData('redirecturl', 'http://something here');
    }
.
.
.
.



Cheers
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.