Before you read the solution, I suggest few things-
1. Have tried anything of your own before posting the question here? If not then you must give a chance to yourself. Then if you find any difficulties then you can definitely come back here and ask the specific problem.
It's never a good idea to copy all the codes from somewhere else as in real life you'll have to code for some functional requirement specific to the project.
2. Before asking any question, try seaching the same in GOOGLE.
Take a look on the following links-
PHP Login Form with Sessions[
^]
PHP Login Page Example.[
^]
PHP Login Page Example with Demo[
^]
If these don't help check
GOOGLE search result.
Hope, it helps :)