Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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..
Reply With Quote
  #2 (permalink)  
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~
Reply With Quote
  #3 (permalink)  
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
Reply With Quote

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 03:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.