Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 16. apríl 2024
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Filter Problem

phpMyEdit General     Filter Problem
Odoslať novú tému   Odpovedať na tému    
 
Taffman     Založený: 09.05.2014   Príspevky: 5  
Príspevok Zaslal: 2014-05-09 11:21
Návrat hore  Odpovedať s citátom     

Hi, I have a page where the user name I want to use in a table filter is sent to the page from form data using the GET POST method.

The form sends the username to this script and sets via $_POST["name"]

I have set the following variable in my script:

$call_query = $_POST["name"];

I have set a filter as follows:

$opts['filters'] = 'PMEtable0.oper = "'.$call_query.'"';

This works and the table is displayed correctly filtered.

However if I try and sort, filter or search on this table no records are returned. It's as if the $user_name is lost once the table has been rendered.

I have read that there is an option called persist that may help here but I don't seem to be able to get that to work. This is what I'm using:

// Make valid_user persistent

$opts['cgi']['persist'] = array('PMEtable0.oper' => $call_query);

Any help in getting this to work would be much appreciated.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2014-05-09 19:54
Návrat hore  Odpovedať s citátom     

An example using sessions to store a value:
// If your user session ID is set as $_SESSION['user_id'] then

if(!empty($_SESSION['user_id'])){

$opts['cgi']['persist'] = array('user_id' => $_SESSION['user_id']);

}

 
Taffman     Založený: 09.05.2014   Príspevky: 5  
Príspevok Zaslal: 2014-05-10 19:51
Návrat hore  Odpovedať s citátom     

Hi Doug, thanks for the reply. I'm not using sessions. All Im trying to do is use html get post from a form to pass a name to pgpMyEdit and use that name in a filter to filter the records displayed. This works but the filter value passed in $_POST["name"] ios not persistent i.e. records are lost if I attempt to use navigation, sort or filter.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2014-05-10 20:20
Návrat hore  Odpovedať s citátom     

$call_query is empty following any action because you are not using sessions, thus you should be using sessions to store the value.

 
Taffman     Založený: 09.05.2014   Príspevky: 5  
Príspevok Zaslal: 2014-05-10 21:10
Návrat hore  Odpovedať s citátom     

Ok so in your example, do I replace 'user_id' with $call_query?

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2014-05-10 23:54
Návrat hore  Odpovedať s citátom     

Much of my work with persistent variables is done using sessions. I can't quickly locate a non-sessions based example in my recent work. Sessions would be useful if tracking the user ID of the logged in user, and restricting them to viewing ONLY those records which are associated with their ID.

So try instead:

// insecure
// $name = $_POST["name"];

// more secure, works with either GET or POST
$name = array_key_exists('name', $_REQUEST) ? @get_magic_quotes_gpc() == 1 ? trim(stripslashes(strip_tags($_REQUEST['name']))) : trim(strip_tags($_REQUEST['name'])) : '';

if($name != ''){
$opts['filters'] = 'PMEtable0.oper = "'.$name.'"';
$opts['cgi']['persist'] = array('name' => $name);
}

 
Taffman     Založený: 09.05.2014   Príspevky: 5  
Príspevok Zaslal: 2014-05-19 13:17
Návrat hore  Odpovedať s citátom     

This works great, many thanks for your help.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov