Game help

i need some help with this, if i have a global variable that is the HP of the player and level only allows a certian amount of HP per level, like say 400HP= level 1 or 500HP= level2. If the player picks up a healing or something like that how can i make it so that it rembers the players HP for the level that the player is on and dosent go over it to fulfil the HP.