This is a common problem about sharing data.
As i am building a system that allow user share their mailing list to their colleague.
I suspect there is a problem when userA open the page ,
userB open the same page and edit the data,
after that user A edit the data and submit and the changes of userB will be cancel.
As i am using PHP , is their any way to prevent this kind of error??? Thank you.|
Are there any coding example provided in php /jquery??? Thanks a lot
Make editions log, so user A will update conent ver. 123 to ver. 124 , user B will try too to update ver. 123 in his own way, but on server there is already ver. 124, so you will show message to user B, that content was recently modified by another user.
This principe is used in SVN for example.
There are a few solutions.
The simplest would be to have a "lock" field on a database which is set to true when someone is looking at a page, and refuses to let anyone else enter the page while it is locked. This isn't a great idea because it's difficult to capture when someone has left the page, so the page might remain locked forever.
You can get around that problem by using a little AJAX call that sends a message to the server to lock the page every ten seconds or so, and the page locking has a thirty-second time limit.
Perhaps the best method (although this depends on the system) is to use AJAX to dynamically reload components of the page when they are edited by another user (and to put a message next to them when they are being edited), and to warn both users if they are editing the same field at the same time.
Related
I am looking to create a setup for my website that a webmaster can complete to setup the required features of the webserver, such as the database, an administrator account, etc.
What I have planned so far is a $_GET variable will automatically be assigned (if not already!) to the user, the $_GET variable will be called something such as $_GET['step'] to represent what step the user is on. This will also allow me to easily display the specific form(s) for that specific step. For example, display the 'Database Setup' form on step 1, but then on step 2 display the 'Create an Administrator' form. I would do this by using switch statements.
However, if there was an error with the information that the user has given, such as a connection cannot be established with the given information, how would I check the information that was inputted and then display an error to the user, forcing them to change the information in the form, if they have been redirected to step 2 when they submitted the form?
Thanks,
Kieron
EDIT: Here is a Pastebin link to what I have so far: http://pastebin.com/Y6YSTrgR
I couldn't put it directly in this post as it wasn't formatting properly.
You've not shared enough technical detail for this question to be helpful, however if I understand you correctly then you could save each step into the session so that you can go back if necessary. This way you could persist the data if the user finishes the last step. If the user doesn't finish the last step, nothing has changed on the server.
Really you need to tell us more about the system, such as which framework you're using (if any) and describe more about how the overall process should work.
I am helping develop a web application for one of the departments in the company I work for.
I was asked to look into a way to log off every user that might be on the application at once, so that if updates to the Web App are pushed out, people aren't working with an old version of it.
My problem is that as I am not very savvy with PHP, JQuery, AJAX, etc. which is what we're using, I have not known exactly what to look for.
We have a timer script running every couple seconds in the background, so I was thinking that I could add an admin button that updated a field in the database which this script could check every so often, and if the field was set, the logoff script could be executed. But this seems like a hack to work around the issue.
The guy I'm working with suggested I look into custom SESSION handlers.
What do you guys think? Any ideas?
Any help would be appreciated. Even if it's an idea on what to start searching for.
Thanks in advance!
EDIT: I should mention that this is a one-page web app. The user is not following any links or leaving the page.
Make an entry for logged in users in your database of choice, maybe memcached if performance is a criteria.
Use a custom Session save handler which stores the sessions in database or file. When you want to destroy all sessions, you can clear the storage (be it database, or file).
Start from - http://php.net/manual/en/function.session-set-save-handler.php
What I ended up doing was the following:
I added a field into one of out database tables and checked its value every time our browser tick came through (about every minute or so). If the field is set when the tick comes through, their page is refreshed, thus logging them off the application and destroying their session (We destroy the session when someone leaves the page).
The users cannot log back in until that field has been reverted to '0'
The admin account can change that field with the click of a button. Therefore their field in the database remains as a '0'
It might be kind of a hack, but it's what I could come up with even after everyone's help. The only issue is that it takes a bit to log everyone off. Problems of pulling vs pushing I guess.
And yes, an email will be sent out some time before logging everyone off so they don't lose work.
Thank you all for your help!
I have a problem in my dev Magento store in that I can not save a new customer or edit an existing customer. I get the "Please Wait" box forever. The animation in the box moves a frame or two every so often but otherwise doesn't do anything. If I refresh the page it loads successfully but the changes have not been applied. I get no errors in the logs or on the page. All the other questions people have posted about this are either not related to customers or throw errors. This does nothing....it just sits there. I think it's failing on the validation, but I don't understand why. It doesn't even work when I try to hit the "Save" button without making any changes.
I did recently delete some 35000 customers that were imported from our main store, so I figured that might have something to do with it even though it was working since then and only broke recently. To test I imported an older copy of the database but I continue to have the same problem. At this point I have to imagine it's a file and not a database issue, but despite reverting all recent changes, nothing has helped.
Does anyone have any suggestions on debugging this and/or have you run into this before?
Thanks!
This was the first result on Google when searching "save customer account freeze magento" so I figured I'd include my findings here.
Running Magento CE 1.9.1 but this probably applies to most any installation. For my situation, the customer I was trying to modify had an extremely large address book (well over 100 addresses). Due to Magento's mechanism of validating every Form on the "Edit Customer" page, the browser determined that script execution was taking too long and killed the page.
My solution was to delete a bunch of the addresses with the customer's consent.
Add a few breakpoints in the various Form javascript class to see what the hold up is. For me it was a dead giveaway when the validator was attempting to process thousands of elements.
iam developing a module in Drupal, which needs to have a locking machanism, When one user operating on form submission other should nt take action,
How do i can achieve this in php/drupal
iam using mysql database with MyISAM/INNODB
Please help me
Thanks in advance
Kamal
Drupal 6.16 implemented a locking framework.
http://api.drupal.org/api/drupal/includes--lock.inc/6
If you're in a situation where there's a good possibility where there will be two users trying to do something, outright locking will annoy people.
You can be a lot more clever, storing locks in a database, having the client poll in from the form to let the system know it's still connected, alert other users trying to access the page (by reading the database) and you could even add a notification system so users could click "notify me when I can submit" that stores their session key in another table with a reference to the lock...
Their client keeps polling for notifications and when the lock finishes or expires, you either let them know they can get a lock or automatically give them a lock.
Whatever you do, don't just add some code in that stops the form being processed. It'll make people monstrously unhappy.
I'm new here, also a novice programmer, and not really familiar with PHP. I don't even know the name of some of the techniques I used when building my apps. I'm sorry for that, but I'll try to explain the best I can.
So I'm building a web apps with PHP / AJAX right now, and I've got to the point where some users (with their own privilege) have their own home page, which shows notification for them when something new happened in the system. I think I used the "get" method from the url to determine which page is the user in right now.
Here's a simple illustration :
A user with "Staff" privilege logged in, and then redirected to his home page. (http://localhost/apps/staff.php)
He open the notification page, and the url changes to : "http://localhost/apps/staff.php?cmd=notification"
I don't know the name of the technique, but here's how I do it : I get the cmd value using "$_GET['cmd']" and then pass it onto a function that checks what page to display.
The problem is, I want to delete the content of notification table and move it to the history table when the user leave the page so only the newest notification will shows. So I think I need to know when the user leave (move) to another page, or when the cmd value change. My question is, how ?
Ps. I'm still a student on a university so this is my homework. Please just point me on a direction and/or clue rather than write the code for me (and a clue to the name of that "get" technique is welcomed :p). I know I still got a lot to learn, but english is not my native and I've tried google and stackoverflow with no result (I believe it's because of my bad english and not knowing the name of the techniques I used).
Use a cookie to track the status of the notification.
See this thread for more info: Best way to show an admin message to certain users?
You can check if user went to notification (after his default user page) page like this:
if (isset($_GET['cmd']))
{
// delete old notifications
// and move to history table
// show new ones now
}
This checks if query string value cmd is there, he has moved to notification page.