It's not as easy as you might think. It's not hard but it really depends on what your needs are.
There are plenty of tutorials out there for this type of thing. Google "PHP login script" and you will find a lot sites.
The things that you will need to understand to do this are(and not limited to)
So I would suggest googling it