Hi!
I have a multipage form that checks that Swedish social security number is correctly enterd. If it is correct the form opens the next page. If it already in the database and owns by the current user it will put the Array in a new form for editing. It woeks fine but now I would allow users to use social security from 2 other countries. I have tried to set up Three textfields that is chosen from a drop-down list. My problem is how to test and check this fields depending of what has been choosen in the DropDown-list??
This is the code I use in Event Switcher.
Here I use textfield pnr-s and that works. Now I would like to test pnr-f and pnr-n and this I can´t get to work.
//JeLu
I have a multipage form that checks that Swedish social security number is correctly enterd. If it is correct the form opens the next page. If it already in the database and owns by the current user it will put the Array in a new form for editing. It woeks fine but now I would allow users to use social security from 2 other countries. I have tried to set up Three textfields that is chosen from a drop-down list. My problem is how to test and check this fields depending of what has been choosen in the DropDown-list??
This is the code I use in Event Switcher.
<?php
$user =& JFactory::getUser();
$user_id = $user->id;
$pnr = '';
if ( isset( $form->data['pnr-s'] ) ) {
$pnr = $form->data['pnr-s'];
}
if ( !preg_match( "/^\d{8}\-\d{3}\w{1}$/", $pnr ) ) {
return 'event_b';
$form->errors[''] = 'My error message';
}
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__MyTable`
WHERE `pnr` = {$db->quote( $pnr )};
";
$db->setQuery($query);
$rows = $db->loadObject();
$actual_user = $rows->cf_user_id;
$pnr_exist = $rows->pnr;
if ( $actual_user == $user_id) {
return 'event_a';
}
elseif ( $pnr_exist ) {
return 'event_d';
}
else {
return 'event_c';
}?>
Here I use textfield pnr-s and that works. Now I would like to test pnr-f and pnr-n and this I can´t get to work.
//JeLu
Hello JeLu,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How do I prevent a list of previous results showing?
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How do I prevent a list of previous results showing?
P.S: I'm just an automated service😉
Hi!
I used this code and it looks like it works.
DropDown list works and it checks on each pregmatch. Now I have to figure out how I can save it to DB as pnr?
//JeLu
I used this code and it looks like it works.
if ( $form->data['country_set']=='1' ) {
$pnr = '';
if ( isset( $form->data['pnr-s'] ) ) {
$pnr = $form->data['pnr-s'];
}
if ( !preg_match( "/^\d{8}\-\d{3}\w{1}$/", $pnr ) ) {
return 'event_b';
$form->errors[''] = 'My error message';
}
}elseif ( $form->data['country_set']=='2' ) {
$pnr = '';
if ( isset( $form->data['pnr-f'] ) ) {
$pnr = $form->data['pnr-f'];
} if ( !preg_match( "/^\d{11}$/", $pnr ) ) {
return 'event_b';
$form->errors[''] = 'My error message';
}
}else {
$pnr = '';
if ( isset( $form->data['pnr-n'] ) ) {
$pnr = $form->data['pnr-n'];
} if ( !preg_match( "/^\d{11}$/", $pnr ) ) {
return 'event_b';
$form->errors[''] = 'My error message';
}
}
DropDown list works and it checks on each pregmatch. Now I have to figure out how I can save it to DB as pnr?
//JeLu
This topic is locked and no more replies can be posted.