php: prevent other users from saving data
Posted: Tue Jul 12, 2011 11:39 am
hi everyone:
i have created a login script using sessions which works great. it displays the users sign on name on each page and i record their name when they save data into a mysql database.
i have an issue when two users (or more) save data at the same time. i have a page which allows users to transfer data from one table to another e.g. perform an insert from data from one table into another table, then delete the data from the original table. A problem occurs when two users have the same page open at the same time. If the first user transfers the data (the content then doesn't exist in the original table), then another user attempts to transfer the data, their name is inserted into the destination table with no other data as it doesn't exit in the original table. i need to prevent the second user from transferring data if it no longer exists. what is the best way to prevent this?
thanks.
i have created a login script using sessions which works great. it displays the users sign on name on each page and i record their name when they save data into a mysql database.
i have an issue when two users (or more) save data at the same time. i have a page which allows users to transfer data from one table to another e.g. perform an insert from data from one table into another table, then delete the data from the original table. A problem occurs when two users have the same page open at the same time. If the first user transfers the data (the content then doesn't exist in the original table), then another user attempts to transfer the data, their name is inserted into the destination table with no other data as it doesn't exit in the original table. i need to prevent the second user from transferring data if it no longer exists. what is the best way to prevent this?
thanks.