Originally Posted by Vernk
Yea they have to be logged in. But the problem is when they keep clicking the button it keeps uploading and running the query , so they can get tons of credits
I believe you can use mysql_affected_rows for this. If its an update and no field data has actually changed, I believe it relays the count excluding that record.
So after the first update, simply add in:
if (mysql_affected_rows() <= 0)
mysql_query("UPDATE userinfo SET credits = credits + 1000 WHERE id='$uid'");
Assuming that userid and id are a composite key on referr, that should only ever be 0 or 1 if the affected rows works as I think it does.
If it does not, simply issue a select first, then issue an update. If the record is already set at 0 (or doesn't exist maybe?), then update.