Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 9th, 2009, 05:37 PM
Registered User
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with admin login

Thanks a lot Thomas for this wonderful book though the codes are not working 100%.

I started to copy the part of the code as soon as I am instructed to do so . I mean I am just following your book. So far I done up to chapter 4. I skipped chapter 5 (cart) and started to build the dashboard. At this point I am facing problem with admin login.

Here are my model, view and controller:

class MAdmins extends Model{

    function __construct(){
    function verifyUser($u,$pw){
        $this->db->where('password', db_clean(dohash($pw),16));
        $this->db->where('status', 'active');
        $Q = $this->db->get('admins');

        if ($Q->num_rows() > 0){
            $row = $Q->row_array();
            $_SESSION['userid'] = $row['id'];
            $_SESSION['username'] = $row['username'];
            $_SESSION['userid'] = 0;
            $this->session->set_flashdata('error', 'Sorry, your username or password is incorrect!');
function verify(){
    if ($this->input->post('username')){
        $u = $this->input->post('username');
        $pw = $this->input->post('password');
        if ($_SESSION['userid'] > 0){
    $data['main'] = 'login';
    $data['title'] = "S & G Suppliers - Admin Login";
    $data['navlist'] = $this->MCats->getCategoriesNav();
    $this->load->view('template', $data);  
<h2>Please login to Access the Dashboard</h2>
if ($this->session->flashdata('error')){ 
    //echo "<div class='message'>";
    echo $this->session->flashdata('error');
    //echo "</div>";

$udata = array('name'=>'username','id'=>'u','size'=>15);
$pdata = array('name'=>'password','id'=>'p','size'=>15);

echo form_open("sellside/verify");
echo "<p><label for='u'>Username</label><br/>";
echo form_input($udata) . "</p>";
echo "<p><label for='p'>Password</label><br/>";
echo form_password($pdata) . "</p>";
echo form_submit('submit','login');
echo form_close();
class Dashboard extends Controller {
  function __construct(){
    /*if ($_SESSION['userid'] < 1){
First of all the error tells me that:
"Fatal error: Call to undefined function db_clean() in C:\wamp\www\s_g_suppliers\system\application\model s\madmins.php on line 11"
"Fatal error: Call to undefined function dohash() in C:\wamp\www\s_g_suppliers\system\application\model s\madmins.php on line 12"

If I remove the functions then I cannot simple log in. I think the problem is because of not using the dohash() the password is not matched with the actual entry. Why it says that the functions are invalid. A I told you i did not copy the entire codes after I downloaded it. I downloaded CI and started to change it according to your book. Is there any place where I should add some librery functions?

Last edited by thoque; July 9th, 2009 at 05:43 PM..
Old August 13th, 2009, 05:14 AM
Registered User
Join Date: Jan 2004
Location: Tawau, Sbh, Malaysia.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

Hi dude,
you problem is because u didn't create the MY_security_helper.php file, which has the id_clean, and db_clean function, go to the website download the full version of source code and run it, or u read ur book carefully again.

Bless you~
Old August 13th, 2009, 08:37 AM
Wrox Author
Join Date: May 2008
Location: Austin, TX, USA.
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
Default mmm, db_clean

I introduce the concept of db_clean() in chapter 9, which is part of a refactoring discussion on security. Originally though, in chapter 6, I wanted you to create some functionality without the extra security so that we could later go thru refactoring.

If you're going to use the code from the download (instead of typing it in by hand) then you need to grab all of the code, including the helper file that contains the db_clean() function....sorry if this is confusing.
Thomas Myer
Author, Professional CodeIgniter

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant Login in Admin pollers BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 9 September 5th, 2009 11:56 AM
CMS - admin login does not work peppie BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 October 20th, 2007 08:46 AM
Admin login help banned Classic ASP Databases 2 May 8th, 2006 07:50 PM
admin login mujnu PHP How-To 0 February 5th, 2006 08:03 AM
can't login into PHPNuke as admin anshul Pro PHP 0 August 5th, 2004 04:16 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.