How do I restrict a person from seeing evrything that I have on my database to them seeing only their information and products for them to be able to UPDATE,EDIT and DELETE their own only
How do I restrict a person from seeing evrything that I have on my database to them seeing only their information and products for them to be able to UPDATE,EDIT and DELETE their own only
Thanx
Use a where condition in the select query where you display the records
For eg, if the user with the id #2 is logged in , put this id in the session, then the qry will be as
$sql = mysql_query("se lect * from tableName where id = '".$_SESSION["id"]."'") or die(mysql_error ()) ;
you need to make sure that the product table has the foriegn key which is the primary key of the users table
Use a where condition in the select query where you display the records
For eg, if the user with the id #2 is logged in , put this id in the session, then the qry will be as
$sql = mysql_query("se lect * from tableName where id = '".$_SESSION["id"]."'") or die(mysql_error ()) ;
you need to make sure that the product table has the foriegn key which is the primary key of the users table
Thanx for the reply.
but my primary key at the moment is the supp_name I dont have the id as its the foreign key on the product table or do I need to change the table structure to have the id
but my primary key at the moment is the supp_name I dont have the id as its the foreign key on the product table or do I need to change the table structure to have the id
yes it will be better if you change the table structure, so that it can have the foriegn key as the user's id in the product table
yes it will be better if you change the table structure, so that it can have the foriegn key as the user's id in the product table
Hi I changed my structure but now adding a product gives me a hassle even though a supplier is registered it does not want to add their products it goes to foreign key constraint errer as if the supplier is not registered.If they are not I know it does that.
Hi I changed my structure but now adding a product gives me a hassle even though a supplier is registered it does not want to add their products it goes to foreign key constraint errer as if the supplier is not registered.If they are not I know it does that.
Oh I can add the product from the mysql but then how do I define the user_id for it to know which id I am adding the products to. Can I use '".$_SESSION["user_id"]."' even though I am not using them anywhere in my coding???
Oh I can add the product from the mysql but then how do I define the user_id for it to know which id I am adding the products to. Can I use '".$_SESSION["user_id"]."' even though I am not using them anywhere in my coding???
Whenever the user enters the site, he/she might be adding products to the shopping cart at that time you need to assign the session id (session_id ) or currernt time() as the cart id and this will be stored in the session value, say $_SESSION["CART_ID"],
Now you'll be insetring a new record in the products table each time whenever user clicks on the add to cart, with the session cart id ($_SESSION["CART_ID"]) maintaing in the table. Now whenever you are inserting the product in the table, you need to insert the product information, session cart id ($_SESSION["CART_ID"]), and the user id , again the user id is also going to come from the session $_SESSION["USER_ID"],if the user is logged in , if the user is not logged in leave it as empty, at the time of checkout you'll ask the user to login to the site, now put the user id in session and update the product table, for eg,
update product_table set user_id = '$_SESSION["USER_ID"]' where cart_id=$_SESSI ON["CART_ID"];
Hope this is clear to you, if you have any queries get back to me
After logging on a Student has to view their school progress and test marks, how do I make sure that they are restricted to only their information and not of fellow mates? Coz now everybody sees everybody's marks which is not acceptable.
Assuming your using a Database such a SQL server, Mysql.
you need to add a where statement.. Ex.
SELECT * FROM Database WHERE student_id = 1
student_id should beable to be retrieved from the session when the user logs in, if you don't have user_id's or session_id's you need to think for alittle bit and get some of this stuff coded in.
I never understood which is the reason why I am trying again now
If you don't understand the code shown to you in this forum, you must either tell the poster that you don't understand it or try to upgrade your PHP knowledge to a level where you can understand it.
But do not post the same question again and again. People get tired over that, because it distracts their attention, away from other members who also have problems.
If you don't understand the code shown to you in this forum, you must either tell the poster that you don't understand it or try to upgrade your PHP knowledge to a level where you can understand it.
But do not post the same question again and again. People get tired over that, because it distracts their attention, away from other members who also have problems.
There is no need for this kind of beligerant post.
Abusive behaviour is not tolerated on these forums and any further abusive behaviour will be met with swift action.
You have stated yourself that you did not understand the answer that was originally provided for you.
The reply that you either "say what it is you don't understand" or "attempt to learn more about php so you can better understand the original reply" is not unreasonable. Either course of action is likely to lead you to a solution.
What wont lead you to a solution is name calling and refusing to provide requested information about your problem.
I am going to merge this thread with the original thread and then I suggust you
1. Appologise
2. Give a more indepth description of what it is you don't understand.
Comment