CaptainChainsaw Posted July 23, 2008 Share Posted July 23, 2008 Hi all, I'm using quick form to create my forms and I'm in the process of authenticating users against the database. $form = new HTML_QuickForm('login', 'post'); $form->addElement('text', 'username', $conf->getConfItem('elementusername')); $form->addElement('password', 'password', $conf->getConfItem('elementpassword')); $form->addElement('submit', 'btnsubmit', $conf->getConfItem('elementbtnsubmit')); $form->registerRule('checkauthusername', 'callback', 'checkforauthusername'); $form->addRule('username', $conf->getConfItem('ruleusernamerequired'), 'required'); $form->addRule('password', $conf->getConfItem('rulepasswordrequired'), 'required'); $form->addRule(array('username', 'password'), $conf->getConfItem('rulecheckforauthusername'), 'checkauthusername', $db); // the last line is the offending line. I need to pass the username and password // to my custom validation function so it can go and look up the database to see // if the username/password combo are correct. In my custom validation function I have: function checkforauthusername($arr[0], $arr[1], $db){ echo "username = $arr[0], password = $arr[1]"; } I've tried passing them like so too: $form->addRule('username', 'password', $conf->getConfItem('rulecheckforauthusername'), 'checkauthusername', $db); and also changing the validation function like so: function checkforauthusername($username, $password, $db){ echo "username = $username, password = $password"; } Nothing echoes out to the browser when in checkforauthusername(); Anyone got any ideas on this one? CC Link to comment https://forums.phpfreaks.com/topic/116288-solved-user-authentication-using-quickform/ Share on other sites More sharing options...
CaptainChainsaw Posted July 23, 2008 Author Share Posted July 23, 2008 Problem solved, was passing array so had to do: function checkforauthusername($array $db){ echo "username = $array[0], password = $array[1]"; } and this line for my form: $form->addRule(array('username', 'password'), $conf->getConfItem('rulecheckforauthusername'), 'checkauthusername', $db); Link to comment https://forums.phpfreaks.com/topic/116288-solved-user-authentication-using-quickform/#findComment-597979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.