I wonder if it is? If it is correct? Will there be any future problems with this algorithm? Maybe someone will find tips or ready narabotki, open source projects?
A cursory examination - I think so. I wouldn't complicate the logic so. Way easier in my opinion:
1. Is the exp value of the current user
2. Have either levels table (1=20, 2=30, 3=40 etc.) or algorithm that calculates this level on the count of experience.
This probably all. Further, the user got exp he added ACC. Qty.
I imagine so, in the users table has columns: level, current_expierence, next_level_expierence.
next_level_expierence is only needed if all users number exp. to the next level different, i.e., one for level 5 you need 100exp, the other to level 5 you need 200ехри etc., resp., for column level - about the same, with respect, it is necessary only in case if we don't hand calculate that number for the current user-specific.