Free and Very Simple PHP Authentication Login Script for Existing Database User names and Passwords!
Easily authenticate user names and passwords from a different kind of script! No PHP knowledge needed.
No PHP knowledge needed? What is this?:
Looking build a members only section but you want your members to be able to use the same username and password as they do on your forums or something similar to this? Not a problem. Below is a simple 3 step process you can take to setup the user authentication. After you have everything setup, all that is left is the layout for you to build. Don't know much PHP? You don't need too. Nothing in the script requires you to know any PHP at all. However, for those who do want to learn, the PHP files are heavily commented so you know exactly what is going on during each function.
You will need to be a registered member to download any file on our website. Registration is free and easy. Simply sign upon the left navigation menu.
This script was built and rendered from a script made by 'Munk' which allows a connection to a brand new database and does the same thing basically. If this is something you are looking instead of using a existing database, you will definitely want to visit his website and download his version of the script. It's developed for someone who wishes to start a new database of usernames and passwords instead of using a existing MySQL database to authenticate users to a members only page.
Installation & Instructions
Windows Users: You will be asked to be able to locate certain lines throughout these instructions. I would recommend opening these files in 'Notepad', *not* Wordpad. You can overcome this by clicking the [View] tab up at the top and choosing the [Status Bar] option. Now in the lower right corner of your notepad you will see something like [Ln 1, Col 10]. The "Ln" stands for what line of the notepad you are on. Line 1 would obviously be the very first line in a Notepad. Line 2 would be the second, and so on.
Linux Users: You will be asked for the same, but if your running Linux you should already know this. Simply open any of these files in pico/nano. Go down a few random lines and hold down the [CTRL] button on your keyboard, then hit letter [C] one time and release all buttons. Your text editor will display which line you are on.
List of Script Files you should have:
A. Modifications to config.php
1.) Open config.php in notepad, nano/pico, or other text editor.
2.) Go down to line 104 and read the template and instructions given. After you understand them move to instruction 3.
3.) Skip to line 120. Edit lines 120, 121, 122, 123 with your existing MySQL database settings. If your not sure what they are, you can open the configuration file of one of your existing scripts that connects to the database in question. You could also just ask your host how you can find this information.
4.) Save changes/settings to file.
B. Modifications to functions.php (Most important part. Allows connection of existing MySQL Database)
1.) Open functions.php in notepad, nano/pico, or other text editor.
2.) Go directly to line 177. On this line you will make (3) changes.
If you do not know what to change these two, please open your existing database in PhpMyAdmin and navigate to the table on the left menu in PhpMyAdmin to the table that contains the usernames and passwords that will authenticate.
This should provide you with the table name, and the username and password field names. You may have to click [Browse] in PhpMyAdmin to verify if a table contains this information, and/or to see the field names that contain this kind of data.
3.) Save changes/settings to file.
No other modification should be necessary to get the script functional. If everything is operating as expected, you can then proceed making all of the changes to the template, pages and coding to fit your web site or needs.
I'm not too great in PHP like most of you who are probably reading this article. However, I will be happy to answer what questions you might have if you please direct all questions to the forums. You must be a registered user in order to submit a thread. So, make sure you grab a account before attempting to do so.
Here is where you can submit your questions regarding this script:
Authintication Existing Database Script Question Forum
Mod_AuthMySQL Apache Module
Now there is a much easier way to authenticate to a existing database the same way using a Apache Module called Mod_Auth_MySQL that can be downloaded for free from Source Forge if your running a dedicated server. If your on a Shared Host like me, more than likely Mod_Auth_MySQL will not be allowed to be compiled into Apache.
This module basically allows you to do the same thing much easier. Instead of installing a script to authenticate to a existing database, all you do is write a few .htaccess rules to do so. Table, Username Field, and Password fields is all you really need to specify in your .htaccess file on your host. If anyone is would like further instructions on this, ask your host if your already running the module or if it can be installed. If so, use the forum or contact page to request these instructions. I may just post them in this article if there is enough requests for them.