Well the idea behind a facial recognition program is that a set of points on an image create an "image signature" which is unique. Storing this signature can then allow you to compare an image you choose and its signature to other matches with an exact or a close number of points (if it matches 8 out of 10 points on the image would be a high probability match for instance).
All you need to do is create a script that can first generate this signature from a file (look into the image functions of PHP), store them in a database table, then create a search algorithm against those signatures to identify high probability matches. How you setup the signature definition will dictate how you search and how effective it will be in finding close or exact matches.
I hope this make sense and gives you some ideas on which direction to proceed with.