Sounds like homework! See forum Rule #1.5.
And please do not hijack someone else's thread. Prefer to start a thread of your own.
Hint - try using the search feature of this forum.
It is your responsibility to die() if necessary….. - PHP Manual
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 01-21-2013 at 07:51 PM..