I will admit I am very new to PHP and have only elementary understand of the language, so when it comes to figuring out how to integrate a PHP app into our ModX site, I am unfamiliar with what is normal php and what is ModX specific. I of course want to learn to do this myself, but the deadline for this project is coming up at the end of the year, so any specific help you guys could offer would be great. As I mentioned, because my understanding of php is limited, many of the forum results and ModX manual online is not of a lot of help since I am having a hard time deducing what applies to my code.
The Project: simply put this is a User Authentication app. We have a member's only section of our website and need to register users, then when they login - authenticate the login against the database. The Member's only content is free, so security isn't a big deal here, but I was able to find a great collection of code here:
https://github.com/elpeyotl/Secure-login-and-registration-form - I updated the necessary files to point to the SQL database I plan to use, and the scripts worked great outside of ModX; however I don't know where to begin in terms of getting all of code into ModX.
Components of the app:
- PHP code on secured pages - (checks to see if they are logged in - usually goes above Doctype)
- User Registration page - (takes username, email, password, hashes password to SHA-512, and sends to SQL database)
- User Login Page - (takes the email/username and passwords, and checks with database record, redirects to secured home page if successful)
- Login processing and Hashing scripts - (PHP script for login processing, Javascript for SHA512 hasing)
- Functions PHP script - (holds all of the functions used through the scripts.)
Obviously there is a bit more to it, but this is kind the gist broken out. I assume that the Login and Registration bits are resources, the secure code that checks if you are logged in would go on in a template for the secure pages, but that is all I know for sure.
I did come across this page:
http://stackoverflow.com/questions/18449880/custom-php-in-modx-with-a-snippet that mentioned adding the "if function_exists" before each function, but that did not seem to help.
I can post any bits of my own code or the original code if it would help, but I did not want to clutter this up if you guys preferred to just download the github project and see for yourself.
Thank you in advance for any advice you can give. I know I am asking a lot, but I hope you guys are able to point me in the right direction.