Add php login script, and fix bugs