For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > January 2007 > Re: Access Control with PHP and MySQL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Access Control with PHP and MySQL
J.O. Aho

2007-01-17, 8:01 am

neil.mcdonald@blueyonder.co.uk wrote:
> Hi,
>
> I'm new to PHP and MySQL, and need to implement an access control
> system similar to many web retailers:
>
> The database will track jobs, so a person needs to be able to enter a
> new job onto the database. That job will be allocated at the entry
> stage to an engineer.
>
> What I need is for only the person entering the job and the engineer to
> be able to see that particular job. i.e. each of them sees only the
> jobs relevant to them.
>
> Can anyone give me any suggestions about how this might be implemented
> with PHP and MySQL? I'm very happy to go and learn the details if
> someone can give me an outline of how this can be achieved.


You add a column for the user who enter the job and one for the engineer, when
checking to show the data, you compare if the user logged in is one of them

$query="SELECT * FROM yourtable WHERE (job_inscriber='$userloggedin' OR
engineer='$userloggedin') AND job_id='$jobid_searched'";

That query would prevent anyone else than the engineer and the user who filed
the job from seeing it, of course this require you to have a login system.


--

//Aho
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com