|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
mysql safe transaction
Hi!
I'm stuck in a comum problem. I have a script that add a user at database. But it can't have duplicate email. So, my script do the follw: //1 receiv the post data if(NOT exist email at base): //2 do things that spend about 1 seconds if(things above is sucessfull): //3 insert into base endif; endif; the problem is that: if the user click twice the submit button of the form that send data to this script, BOTH request is processed, and enter the first IF, and so, insert twice at base. I try using LOCK tables WRITE, but it's not good. I'm getting my table locked sometimes forever, having to restart mysql. And COMMIT is not supported at mysql. What can I do? |
|
#2
|
|||
|
|||
|
RE: mysql safe transaction
I suggest you use a javascript that disables the submit button to prevent this from happening.
onClick = "document.formname.submitname.disabled=true" this will disable the submit button after the first click. |
|
#3
|
|||
|
|||
|
RE: mysql safe transaction
Thanks Blindeddie! very creative! This will help me too.
But I want to garantee tha a opera browser that can easy disable javascript, or a hack atack won't duplicate the login's too. And i want to know how lock correctly a table, cause I have others situations too. Any body else! |
|
#4
|
|||
|
|||
|
RE: mysql safe transaction
Unfortunatly I do not have a lot of experience with locking tables so I can't give you any advice in that department. If you are using MySQL 4.0.12, you can use transactions, but the table types need to be InnoDB. Here is a link to an article on the subject.
http://www.devarticles.com/art/1/555 As far as the javascript problem, I would use the get_browser() function to determine if javascript was enabled and then redirect to a page that tells the user javascript needs to be enabled in order to use the site(if it detects that javascript is not enabled) Just a suggestion. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > mysql safe transaction |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|