Codeigniter validating dates

Posted by / 19-Oct-2020 00:13

Instead, it's easier to make the member variable protected or private (in order to make the setter the only access point) and to validate in the setter because then you'll know that the object contains a valid birth date no matter which part of the application the object came from and if you want to add more validation then you can add it in a single place.

You might want to add multiple formatters that operate on the same member variable i.e. getters and setters are also useful when you extend objects.

View Demo For novice users let me explain what this article is all about. You have multiple employee each has their specific roles.

i.e some person are responsible for feeding data (Data Operator), some are responsible for customer support and some for sales.

In this case you don’t want all your modules/data to be available to every one of them.

So what you have to do is to assign a role to them, and then they will have the privilege to access limited data only. Create some modules that you will be using in your application. CREATE DATABASE `multi-admin`; USE `multi-admin`; CREATE TABLE IF NOT EXISTS `module` ( `mod_modulegroupcode` varchar(25) NOT NULL, `mod_modulegroupname` varchar(50) NOT NULL, `mod_modulecode` varchar(25) NOT NULL, `mod_modulename` varchar(50) NOT NULL, `mod_modulegrouporder` int(3) NOT NULL, `mod_moduleorder` int(3) NOT NULL, `mod_modulepagename` varchar(255) NOT NULL, PRIMARY KEY (`mod_modulegroupcode`,`mod_modulecode`), UNIQUE(`mod_modulecode`) ) ENGINE=INNODB DEFAULT CHARSET=utf8; INSERT INTO module (mod_modulegroupcode, mod_modulegroupname, mod_modulecode, mod_modulename, mod_modulegrouporder, mod_moduleorder, mod_modulepagename) VALUES ("INVT","Inventory", "PURCHASES","Purchases", 2, 1,'purchases.php'), ("INVT","Inventory", "STOCKS","Stocks", 2, 2,'stocks.php'), ("INVT","Inventory", "SALES","Sales", 2, 3,'sales.php'), ("CHECKOUT","Checkout","SHIPPING","Shipping", 3, 1,'shipping.php'), ("CHECKOUT","Checkout","PAYMENT","Payment", 3, 2,'payment.php'), ("CHECKOUT","Checkout","TAX","Tax", 3, 3,'tax.php'); CREATE TABLE IF NOT EXISTS `role` ( `role_rolecode` varchar(50) NOT NULL, `role_rolename` varchar(50) NOT NULL, PRIMARY KEY (`role_rolecode`) ) ENGINE=INNODB DEFAULT CHARSET=utf8; INSERT INTO `role` (`role_rolecode`, `role_rolename`) VALUES ('SUPERADMIN', 'Super Admin'), ('ADMIN', 'Administrator'); CREATE TABLE IF NOT EXISTS `system_users` ( `u_userid` int(11) AUTO_INCREMENT NOT NULL, `u_username` varchar(100) NOT NULL, `u_password` varchar(255) NOT NULL, `u_rolecode` varchar(50) NOT NULL, PRIMARY KEY (`u_userid`), FOREIGN KEY (`u_rolecode`) REFERENCES `role` (`role_rolecode`) ON UPDATE CASCADE ON DELETE RESTRICT ) ENGINE=INNODB DEFAULT CHARSET=utf8; INSERT INTO `system_users` (`u_username`, `u_password`, `u_rolecode`) VALUES ('shahrukh', '123456', 'SUPERADMIN'), ('ronaldo', 'ronaldo', 'ADMIN'); INSERT INTO `role_rights` (`rr_rolecode`, `rr_modulecode`, `rr_create`, `rr_edit`, `rr_delete`, `rr_view`) VALUES ('SUPERADMIN', 'PURCHASES', 'yes', 'yes', 'yes', 'yes'), ('SUPERADMIN', 'STOCKS', 'yes', 'yes', 'yes', 'yes'), ('SUPERADMIN', 'SALES', 'yes', 'yes', 'yes', 'yes'), ('SUPERADMIN', 'SHIPPING', 'yes', 'yes', 'yes', 'yes'), ('SUPERADMIN', 'PAYMENT', 'yes', 'yes', 'yes', 'yes'), ('SUPERADMIN', 'TAX', 'yes', 'yes', 'yes', 'yes'), ('ADMIN', 'PURCHASES', 'yes', 'yes', 'yes', 'yes'), ('ADMIN', 'STOCKS', 'no', 'no', 'no', 'yes'), ('ADMIN', 'SALES', 'no', 'no', 'no', 'no'), ('ADMIN', 'SHIPPING', 'yes', 'yes', 'yes', 'yes'), ('ADMIN', 'PAYMENT', 'no', 'no', 'no', 'yes'), ('ADMIN', 'TAX', 'no', 'no', 'no', 'no'); This step is very easy.

In case if user is trying to access a modules using direct page URL but is not assigned for, they must not passed this security check.

$_SESSION["user_id"] == "") You can also add another layer of security check for each modules pages if you want.Last two weeks I was quite busy with projects and hardly had any spare time left for writing blogs.I had a huge backlog of mails requesting for tutorials.

codeigniter validating dates-69codeigniter validating dates-90codeigniter validating dates-53