That means there's one of two things going on.
1. Your phone is dropping the connection with your wifi router, could be an issue with the phone.
2. Your router is dropping the connection and restarting which is why your phone loses connection.
Two things to try:
Go somewhere else - a friend or family member's house - connect to their wifi and see if the same thing happens. If it does, then there may be an issue with the phone - contact your nearest Apple store.
If it doesn't happen there, then there's possibly something up with your wifi router, or it could simply be that your wifi router is on the same channel as several other routers nearby (neighbours) and is getting interference. Do you know who set up your wifi router? Can they help you to work out what the problem is?