Im using ajax call to insertmsg.php to insert a message.
Now javascript isn’t a realtime language so i can not count on having an disabling button at the top of the ajax function.
So I wonder how I can make a timelimit to the insertmsg.php with:
mysql_query(“INSERT INTO.. , with a delay on 2 seconds, without storing last time the user wrote in the database. Or is that the only way? How can I do it with session maybe?
I think I understand what you want. But you English is very bad…
You want to prevent the user from sending messages at intervals smaller than 2 seconds.
You can do this both on the client side and on the server side, but the client side check can be easily disabled by a willing user.
To do it on the server side, in PHP, you need to store the time when the user last sent a message.
When a call for a new insert is made you just check
Don’t forget to enable you session before using the
$_SESSIONvariable.Or maybe you want your script to do the insert with a delay of 2 seconds?
You can wait in PHP with the sleep function. Or you can delay an action in JavaScript with setTimeout.