Selectall() with db_class
I have added an update to my db_class framework to allow you to select any table from your database. You may pass the new method the table name then what columns you would like to return or you may just say all for all columns. Once you call the method you may display the results with a while statement lie normal.
[php]
$db = new dbcon();
$accounts = $db->selectall(‘accounts’, ‘all’);
while($row = mysql_fetch_array($accounts)) {
print $row['name'];
}
[/php]
Download the db_class here: DB_CLASS.php
Confirm your passwords
I have added a quick function to the auth class that will allow you to check your passwords. You will need to feed the function the password field and the confirm password field. It will check if they match then return TRUE or FALSE if they don’t.
[php]$auth = new auth();
$auth->validates_confirmation_of_password($password,$password2);[/php]
Fixes to the Auth Class
I left out a line in the new class (auth), I did not set the variables inside the class. I have now fixed this problem sorry for any headaches this may have caused!
On another note I added a new function to the class (auth), this function will allow you to validate the uniqueness of an email address within your current accounts. It has both a new account setting and an edit account setting. This will come in handy with signing people up for your application, especially if you only allow one person to have one account per email address.
Below is how to call both new and edit functions.
[php]
$auth = new auth();
$auth->validates_uniqueness_of_email($_POST['email'], ‘new’);
// == OR if this user has an account
$auth->validates_uniqueness_of_email($_POST['email'], ‘edit’);
[/php]
Use the db_class to authenticate
User authentication made easier and less of a hassle to write. Use my db_class to authenticate a user from your database, with all the options you would have if you wrote it yourself! I have also added an “Auto Start” this will start the classes you want right off the bat, saving you one line of code.
Authentication is easy to call, just use the following line.
[php]
$auth->login(‘the_user’, ‘the_password’);
[/php]
All that’s left for you is to build the form and edit the db_class file with the correct settings! Let me know how it works for you, or if you have any issues!
Adding on to the db_class
I am adding a user authentication class to this, as that is something I use on a regular basis. I think other developers will get a lot of use out of this as well. I all put the class up for download sometime this weekend. I will also post more details on how to use it and how to call this class.
Save time with Queries
In developing the June Project and JuneLite I came up with something that was saving me a lot of time. This php class is calling the queries for me all I need to do is write the guts of the query, and if updating provide the record id. This class can connect to your database and then all you need to do is make calls to it below I show you how. In this version of the DB Class I have “Update, Insert and Delete”, I will be working on a method to pull selects out soon, but for now you will have to add your own select queries.
[php]
//==> how to call this
$db = new dbcon();
$db->update(‘table’, ‘row=your data’, ‘id’);
[/php]
The next section of code is how to insert into the database.
[php]
//==> how to call this
$db = new dbcon();
$db->insert(‘table_name’, ‘row=your info’);
[/php]
Categories
Pages
- contact
- Contact Form V1.8
- FlickrHelper
- Guestbook V1.01 ASP
- Guestbook V2.4.7
- iFrame Loader
- Scriptatype:PHP
- Winn Cal
- Winn Tracker
