You will need to build a back end using whatever language you are comfortable with and then access it via the ajax plugin. You will need to set up authentication as well, the safest way to do that is using oauth.
The most common frameworks for developing social game backends from scratch are:
Node.js (Javascript) and Tornado (Python)
You could probably use PHP but it will get messy fast, it will be allright for prototyping though.
For databases the usual suspects; mysql, postgresql and MongoDB will all work.
That's just my 2 cents worth.