Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old June 28th, 2003, 05:37 PM
maka maka is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 8 maka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old June 28th, 2003, 08:53 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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.

Reply With Quote
  #3  
Old June 28th, 2003, 11:51 PM
maka maka is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 8 maka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #4  
Old June 29th, 2003, 04:04 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > mysql safe transaction


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway