With this class you'll be able to easely create a login web page that exams the data in a XML , CSV or database table. the facility of the script lays in that you'll be able to use it on each MySQL database table even on current tables from other tool packages like Wordpress, Mediawiki, MantisBt, ..... This Is because you'll outline a custom password encryption serve as, person and password field. the combination of this functionalities makes it a common usable elegance. I created this class as a result of so much of my clients simply need a simple login shape with out different complex features like user roles and so on.
Use instance:
we have now a database desk that holds our users. in this table there is a box user_field also a password field(pass_field) and a salt box(salt_field). Our password encryption is created like this:
password_hash = md5(password . "-" . salt);To create a loginsystem in accordance with this desk we will use this code:
include("Login.php"); $Login = new Login(); $Login->InitDatabase("localost", "dbuser", "dbpass", "dbname", "user_table", "user_field", "pass_field"); $Login->SetPasswordEncoder("myhash"); // Custom password encoder serve as myhash($password, $fields) return md5($password . "-" . $fields->salt_field); if($Login->Test($_POST'username', $_POST'password')) echo "Correct"; else echo "Incorrect";SHOULD YOU wish to modification this case above to use a CSV document (user.csv) as datasource as opposed to a database table the one factor you need to do is changing:
$Login->InitDatabase("localhost", "dbuser" ....with
$Login->InitCsv("users.csv");or for those who choose xml:
$Login->InitXml("users.xml"); Extendible:The Category may be very easy to increase with some customized code. in the download I included different extension. One for writing login movements to a log record and one that saves the current loggedin consumer in a consultation so that you'll be able to seek advice from different pages without having to login once more. The extensions are really easy to use. the only distinction is that you simply want to come with the extension besides the Login.php class. And in place of creating an instance of the Login magnificence you create an example of the prolonged SessionLogin class. the remaining of the code is the same.
An example how to use the SessionLogin extension:
come with("Login.php"); come with("SessionLogin.php"); $Login = new SessionLogin(); // the remainder of the code is the similar as beforeExamples included:
- CSV document
- MatnisBt database
- MediaWiki database
- Wordpress database
- Xml record
- Login form with sessions
Demo
You Can do a login at the demo page with:
admin/take a look at
sitebase/mypassword
Complete PDF documation may be included in the obtain.
FULL DOWNLOAD
No comments:
Post a Comment