p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 9th, 2009, 06:37 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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:

Code:
class MAdmins extends Model{

    function __construct(){
        parent::Model();
    }
    
    function verifyUser($u,$pw){
        $this->db->select('id,username');
        $this->db->where('username',db_clean($u,16));
        $this->db->where('password', db_clean(dohash($pw),16));
        $this->db->where('status', 'active');
        $this->db->limit(1);
        $Q = $this->db->get('admins');

        if ($Q->num_rows() > 0){
            $row = $Q->row_array();
            $_SESSION['userid'] = $row['id'];
            $_SESSION['username'] = $row['username'];
        }else{
            $_SESSION['userid'] = 0;
            $this->session->set_flashdata('error', 'Sorry, your username or password is incorrect!');
        }        
    }
}
Code:
function verify(){
    if ($this->input->post('username')){
        $u = $this->input->post('username');
        $pw = $this->input->post('password');
        $this->MAdmins->verifyUser($u,$pw);
        if ($_SESSION['userid'] > 0){
            redirect('admin/dashboard','refresh');
        }
    }
    $data['main'] = 'login';
    $data['title'] = "S & G Suppliers - Admin Login";
    $data['navlist'] = $this->MCats->getCategoriesNav();
    $this->load->vars($data);
    $this->load->view('template', $data);  
  }
Code:
<h2>Please login to Access the Dashboard</h2>
<?php
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();
?>
Code:
class Dashboard extends Controller {
  function __construct(){
    parent::Controller();
    session_start();
    /*if ($_SESSION['userid'] < 1){
        redirect('sellside/verify','refresh');
    }*/
  }
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 06:43 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 13th, 2009, 06:14 AM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Tawau, Sbh, Malaysia.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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~
__________________
Hi, Everyone!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old August 13th, 2009, 09:37 AM
Wrox Author
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 25%
Activity: 25% Activity: 25% Activity: 25%
 
Join Date: May 2008
Location: Austin, TX, USA.
Posts: 48
Thanks: 0
Thanked 3 Times in 3 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
http://www.tripledogs.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 12:56 PM
CMS - admin login does not work peppie BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 October 20th, 2007 09:46 AM
Admin login help banned Classic ASP Databases 2 May 8th, 2006 08: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 05:16 AM



All times are GMT -4. The time now is 11:31 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc