First time rigging, help!

So I’m following this tutorial on character rigging. I have a problem that doesn’t show up in the video, however. When I move the characters leg up, the knee looks messed up and the bottom half of the leg gets flattened. Here’s a picture of what I mean:
I’ve tried weight painting it but no matter what I do, it messes it up even more.