|
|
 |
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 computer programmers 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 programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
|
 |

July 9th, 2009, 06:37 PM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

August 13th, 2009, 06: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~
__________________
Hi, Everyone!!!
|

August 13th, 2009, 09:37 AM
|
|
Wrox Author
|
|
Join Date: May 2008
Location: Austin, TX, USA.
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |