Well... you could just do something like...
if(xp >= xpNeeded){
//level up code
}
// That's a REAL simple way to do it.. not the most effective way, but simple. Then just reset their xp and xpNeeded afterwards... keep their actual total in a different variable if you need to display it. If their xpNeeded changes, just change it. Like, if after 5, they need 200 more (instead of 75 or whatever...) just do..
if(level > 5){ xpNeeded = 200}
or create a small formula to do it for you.
xpNeeded = level*100
or something like that.
This is the bare bones, easy to understand way to do it, but not always the best.