I have a master-detail application with one master and two detail pages, like below:
1. Order (Master Page)
2. Test_1 (1st detail page)
3. Test_2(2nd detail page)
Master has a dropdown field (order_Type) with “Standard” and “Target” options. When user select “Standard” option on Master Page and submit then user should redirect to test_1_list.php detail page. Similarly when user select “Target”option on Master Page and submit then user should redirect to test_2_list.php detail page.
I have used this following code on Add Page: After record added event but not working as I expected.
If($_SESSION[‘ord_Type’]==’Standard’)
{
header
(“Location:test_1_list.php”);
} else{
header
(“Location:test_2_list.php”);
}
exit();


if I select “Standard” option in first time then its redirect to the expected test_1_list.php page but after that if I select “Target” option for another order then it is redirect the same test_1_list.php page instead of test_2_list.php.
I used

unset($_SESSION[‘ord_Type’]);
at the end but steel it does not work. Any idea please. Thanks in advance.


Ha ! Ha! Finally I solved it. here is final code could be useful for other members in this forum.

use this all codes on Add page After record added event for Master page:

STEP 1: Save selected value from the dropdown list as SESSION variable:

$_SESSION['dropdown field']=$values['dropdown filed'];


STEP 2: put condition to redirect your expected page:


if ($_SESSION['dropdown field']=='1')//int linked value from db 
{

header
("Location:test_1_list.php");
}
else
{

 header
("Location:test_2_list.php");
}
exit();


Thats it.

Note: This is so far applicable if you have maximum two options in your dropdown list. 

Post a Comment