The best way to learn is by doing. Of course, the risk with flips is that a) if you don't do them right, it's possible to severely injure yourself and b) doing them repeatedly is risky, because eventually, you will get tired and it makes the odds of doing the flip wrong more risky. You can reduce the incidence of the first case by practicing the flips in a safer place such as on a trampoline, in a gymnastics facility, into a pool, with a spotter, etc. This is not a guarantee of safety but it does reduce risk. As for the latter, the key is to practice up until you start to feel exhausted and then stopping until you feel better.
There are techniques that you can do before actually trying the flip, whether to strengthen yourself or to overcome fear. For the former, recommendations include practicing leaping as high as possible and noting the apex of your jump and practicing jump tucks (jumping and tucking without flipping). For the latter, the video I linked has some suggestions involving things like practicing neckbridges to overcome the fear that landing on your upper back will kill you and practicing jumping and landing on all fours (on soft ground) to assure yourself that you can catch yourself midfall. As always, your best bet involves experienced people helping you learn.
There are similar exercises for handsprings. I know that, on the back handspring, the tumbling class I attended used a large foam cylinder over which we did a back-bend fairly slowly and evenly, also propping our legs up to make the kickover easier.