POST variable causing an issue

QuestionsPOST variable causing an issue
Mike Olson asked 2 years ago

Hi again, hoping you can point me in the right direction.

 

When I put a post variable in my where clause the grid fails. When I hardcode the value of the post variable it runs fine. Including the select command here to see if you can find any issues.

 

 

$g->select_command = ”
select
employee_sak,
‘Roles’ as ‘Section’,
role_name as ‘ID’,
role_descr as ‘Details’
from
roles
inner join role_types
on roles.role_type_sak = role_types.role_type_sak
where
employee_sak = “.$_POST[’employee_sak’].”

UNION
select
employee_sak,
‘Vehicles’ as ‘Section’,
vehicle_id as ‘ID’,
type as ‘Details’
from
vehicles v
inner join employee_vehicle_link evl
on v.vehicle_sak = evl.vehicle_sak
where
employee_sak = “.$_POST[’employee_sak’].”

UNION
select
employee_sak,
‘Routes’ as ‘Section’,
route_number as ‘ID’,
route_name as ‘Details’
from
routes r
inner join vehicle_route_link vrl
on r.routes_sak = vrl.route_sak

inner JOIN employee_vehicle_link evl
on vrl.vehicle_sak = evl.vehicle_sak
where
employee_sak = “.$_POST[’employee_sak’];

2 Answers
Mike Olson answered 2 years ago

Ok so apparently we need to set a session variable for it? Why is this necessary?

I got this to work.

if (!empty($_POST[’employee_sak’]))
{
$_SESSION[‘ep_employee_sak’] = $_POST[’employee_sak’];
}
$ep_employee_sak = $_SESSION[‘ep_employee_sak’];

Abu Ghufran Staff answered 2 years ago

Yes, this is required. Complete reason and workflow is mentioned in docs:

https://www.gridphp.com/docs/misc-faqs/#q-how-to-load-grid-based-on-_post-data-from-other-page

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

15 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?