Check if a user has registered during the last hour


I have this piece of code to check if a user has already created an account the last hour:

$result = mysql_query("SELECT * FROM accounts WHERE registration_ip = '$_SERVER[REMOTE_ADDR]' AND created > ".(time() - 3600));

if (mysql_num_rows($result) > 0)

It does not exit as I want it do, i can make how many accounts i want.

You see any obivious problem? My db tablesandfields are correct

Your problem is probably this, $_SERVER[REMOTE_ADDR]

You are embedding that directly into a double-quoted string. When you want to access an array in a double-quoted string you need to put the variable array access inside a pair of curly braces.

Corrected string:

"SELECT * FROM accounts WHERE registration_ip = '{$_SERVER['REMOTE_ADDR']}' AND created > ".(time() - 3600)

Also, alway quote indexes, you used REMOTE_ADDR instead of 'REMOTE_ADDR' or "REMOTE_ADDR"

Hope this helps.