| Index
» Projekty
» phpMyEdit
» Fórum
» Authenticating/Returning only Values for that sessions ID |
 |
tyler
Založený: 30.08.2010
Príspevky: 2
Zaslal: 2010-08-30 05:07
Návrat hore
Odpovedať s citátom
|
Hello, good people. I come here after much searching and trying different things...and basically pulling my hair out.
I want to do what I thought was a simple thing.
On all my PHP pages (outside of phpMyEdit), users have to login. Thus, they have all have a session ID which is referred to as $_SESSION['user_id'] on all of my PHP pages. I always use this in the "where" variable so that they only see their stuff.
When it came time that they needed a form not only to view but to edit data, I turned to phpMyEdit.
However, I can't for the life of me figure out how to do this.
I implemented the "WHERE" filter so I got the first page to display just their data.
However, if they go to add record or change a record, it does not use the where filter and provides them the option of adding data to anybody's userID (I tried hiding this field but this fails...it also then doesn't seem to know what ID field to use).
The docs do say that using this "filter" is for "any generated SELECT statement". Does this mean that it does not apply for an update or insert?
Is is possible to do what I want to do or am I using the wrong program?
Thanks in advance. Any help is great appreciated.
--Tyler
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-08-30 13:02
Návrat hore
Odpovedať s citátom
|
Make the user id persistent (appended to all link parameters and actions).
| Kód: |
| $opts['cgi']['persist'] = array( 'session_id' => $SESSION_ID ); |
| Kód: |
| $opts['cgi']['persist'] = array('user_id' => $your_user_id); |
|
tyler
Založený: 30.08.2010
Príspevky: 2
Zaslal: 2010-08-30 13:54
Návrat hore
Odpovedať s citátom
|
Doug,
Thank you for your quick response.
I didn't entirely understand it because I am more a "figure it out as I go" person (translation: technically unaware of what most find obvious!)
Anyway, do I put those lines in the php file that is created by phpMyEdit or in one of the other two (phpMyEdit.class.php OR phpMyEditSetup.php)?
And what would be the exact lines? Here are my exact session variables:
$_SESSION['user_id']
$_SESSION['user_name']
Thanks again for your help and patience Doug. I am a newbie to phpMyEdit and it does things different that I am used to.
Cheers,
T
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-08-30 14:56
Návrat hore
Odpovedať s citátom
|
Code goes in the created script, not the class file. The following might work, given that $_SESSION is global in scope and as such does not need to be made persistent.
| Kód: |
| $opts['filters'] = 'PMEtable0.user_id = "$_SESSION[{"user_id"]"'; |
A somewhat related example, based on $_SESSION['sess_user_level'] gives the admin (9) more privileges than other users.
| Kód: |
switch($_SESSION['sess_user_level'])
{
Case 9:
$opts['filters'] = 'PMEtable0.deleted = "0"';
$opts['inc'] = 20;
$opts['options'] = 'ACPVDFL';
break;
Case 7:
$opts['filters'] = 'PMEtable0.deleted = "0" AND PMEtable0.forum_id < "200"';
$opts['inc'] = 40;
$opts['options'] = 'CVFL';
break;
Case 0:
default:
$opts['filters'] = 'PMEtable0.deleted = "0"';
$opts['inc'] = 40;
$opts['options'] = 'VL';
break;
} |
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|