Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 28. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Filter Attribute and Hidden Value

phpMyEdit Configuration     Filter Attribute and Hidden Value
Odoslať novú tému   Odpovedať na tému    
 
wpatch     Založený: 21.09.2010   Príspevky: 2  
Príspevok Zaslal: 2010-09-21 21:09
Návrat hore  Odpovedať s citátom     

All first off thanks for phpmyedit. A) Great code, but B) great online documentation.


Problem 1

Filter based on logged in user ID

Table that I am editing includes user_id. I want user x to only see user x's entries, not user y's

Here is what I found out there...but seems to not work.(user_id is both in the table in question and a separate table users)

///////////////////////////

$opts['filters'] = 'user_id = "'.$user_id.'" OR user_id = "public"';

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

Problem 2 I want to then add user_id when a user adds a new entry.

Now normally I would just add a hidden value of user id, then during the normal insert portion of the script add $user_id....but so far inside the phpmyedit code I am a bit lost.

Thanks in advance for any help!

will

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2010-09-22 14:53
Návrat hore  Odpovedať s citátom     

Another example can be found at
http://opensource.platon.sk/forum/projects/viewtopic.php?t=1364687&highlight=persist+user

Use the forum's search feature to look for the words: persist user

 
wpatch     Založený: 21.09.2010   Príspevky: 2  
Príspevok Zaslal: 2010-09-22 17:40
Návrat hore  Odpovedať s citátom     

Think I have the filtering problem all sorted....thanks to Doug's help!

Where I am stuck now is user_id isn't being recognized from login/cookie side to the form/phpmyedit side.

Think what I need to do is either a:

set user_id persistent from the login script....not sure it will pass through the php open/close

or b:

Parse the cookie...select from table users to make persistent in the display code.

I have included a pastebin to help illustrate. It will be persistent for a month:-)

http://pastebin.com/nmJTqCAx

Thanks in advance:-P

wp

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2010-09-23 02:16
Návrat hore  Odpovedať s citátom     

Cookies and login issues are beyond the scope of phpMyEdit. Many good (and bad) examples exist elsewhere, including http://www.php.net/

Cookies are easily forged, thus my hope the secured data is not terribly important should it leak out to unauthorized individuals.

Lacking time to study the posted code in great detail, I did note that
Kód:
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());

is rather insecure and should include a check to make sure $username is not empty. Further, since relying on non-local variables, using sprintf() to create the query string subsequently fed to mysql_query() is generally more secure.

 
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