I do this thing:

mysql_query("INSERT INTO `battle` (img,name,level,life,atk,def,type,username) SELECT img,name,level,life,atk,def,type,username FROM `enemy` ORDER BY RAND() LIMIT 1")or die(mysql_error()); 

But what's the use? When the page is updated, the infa is entered again, how can you do it so that only when you press the key, the infa will be entered? For example: 1. There is a Fight key on the screen 2. In cases if we want to fight, we poke at it and take the enemy out of us 3. But the page is constantly updated and this is constantly entered into info!

How to make that only when you press the key was recorded infa? If you can tell me in detail Thanks in advance

    1 answer 1

    For each request, make a unique key. Those. here the script starts to work, some key is created and transmitted to the hidden field a la:

    $ secretkey = "jng93v";

    and

    <input type = "hidden" value = "jng93v">

    When the request is executed, it checks: is the key transmitted? He sees that the correct one and when the request is executed he creates a new key, but the field remains that old. I.e.

    $ secretkey = "73f48b";

    and

    <input type = "hidden" value = "jng93v">

    Those. they no longer converge and the request will not be executed. I hope you understand my point.

    • hmmm ... I'll figure it out a moment =) - k0mar
    • How to make a key? - k0mar
    • In the sense of? Make random key creation: function generateKey ($ length) {$ chars = 'abdefhiknrstyzABDEFGHKNQRSTYZ23456789'; $ numChars = strlen ($ chars); $ string = ''; for ($ i = 0; $ i <$ length; $ i ++) {$ string. = substr ($ chars, rand (1, $ numChars) - 1, 1); } return $ string; } Then call generateKey (5); - Maxim Tsybanov