This question gets out of the scope of this forum.
Using PHP is widely documented already over the internet. Please do a search on google or on a website like stackoverflow.com
For the "linking" with your C2 application, refer to the "how do I FAQ" (link in my signature), section AJAX.