Now to write a licensing program, you need to create a license key. This can be done by using an md5 hash in assistance with some other algorithm such as rot13. In your online server, put in the key as well as the date of registration and the date of license expiry into a table. When the user loads up the PHP program, it will contact the server and check for the license details based on the registration key. This can be done with AJAX and a link to a file on the server to take, process and send the data back. This way you can also determine if the registration has expired or is due for renewal.
There are a couple of systems that you probably want to look at if you are serious about this:
PHPLicengine seems to be pretty complete with respect to licensing. It does also seem a little bit complex to understand so you would probably need some time to experiment with it. You can install a demo copy but it didn't seem possible to do it in a local test environment so you probably need to put it on the same server you would eventually want to use it from (if you decide to buy it).
Ioncube is a pretty good PHP compiler / encrypter. You need to use this to hide the licensing and protect the code. I did quite a bit of investigation of the various options and I came to the conclusion that this is probably the best one to use. One benefit is that you can use it through their website to encrypt modules as a demo or on a pay-as-you-go basis. Source Guardian and Zend have similar encryption capabilities but the pay-as-you-go seems to be unique to Ioncube. You will find many other encrypt packages out there, but most of them can be pretty easily broken. I believe that only these three actually produce byte-code which is a semi-compiled module that needs a run-time module to decrypt it. Most servers already have the ones for Ioncube and Zend. Apparently, these can be broken as well but it is more difficult.
These aren't free options but you won't find anything free that is worth using for this. You could probably write a simple licensing module yourself but given that PHPLicengine isn't that expensive (to get something that is more than basic) it is worth considering. There may be other licensing solutions that are worth considering but this is the one that I came across.