Jump to content

RalphLeMouf

Members
  • Posts

    153
  • Joined

  • Last visited

Everything posted by RalphLeMouf

  1. I just got it! I noticed on config.php that enable query strings was set to false. I set it to true and it worked. loaded the wrong page and /validate_crendentials was in the url but that's a step. In the meantime I was starting to transfer my files to the latest version. Do you think I'm ok working on 2.0.3 or should I continue to transfer it to 2.1.1? thanks again for all of this help!
  2. which error logs do you need to see off of my MAMP module? Or do you need to see stuff from my logs folder on CI?
  3. I'm using 2.0.3 I guess I'll just download a new one and transfer all my stuff over
  4. I thought it was correct. I guess I thought wrong: $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'root'; $db['default']['password'] = 'root'; $db['default']['database'] = 'cysticlife_CI'; $db['default']['dbdriver'] = 'mysql'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ''; $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_general_ci'; $db['default']['swap_pre'] = ''; $db['default']['autoinit'] = TRUE; $db['default']['stricton'] = FALSE;
  5. Ok - it's a lot so I put a link to it on https://gist.github.com/c349378691b7da7f2a99 I'm not really sure what I'm looking for. I didn't see any database stuff on there
  6. have it. have had it. $autoload['libraries'] = array('database', 'session');
  7. I've done some trouble shooting using $this->output->enable_profiler(TRUE); That being said. The post data is correct but under the query section I'm getting Database driver is not currently loaded . It appears that I'm passing and picking up the data correctly. Just having an issue with my database
  8. Is this impossible to do with just the 3 pages I have? It seems like I should be able to without adding that additional first controller you mocked up
  9. Making progress! With what I currently have, I've avoided the error! It just reloads the form with "/validate_credentials" tacked on to the end of the url. It looks like it's doing it's job by reloading the page if the info the user put in is not validated. Now it seems like a database issue. Here is what I have. Model: <?php class User_model extends CI_Model { function login($data = array()) { // validate data if( !empty($data) ) return FALSE; // retrieve query $query = $this->db ->from('users') ->where($data) ->get(); // Check if query row exists if($query->row()) { // Query row exists, return query row return $query->row(); } else { // Query row doesn't exist, return FALSE return FALSE; } } } View: <title>Login</title> <!--MAKE SURE SIGNED OUT HEADER IS IMPLEMENTED FOR ALL SIGNED OUT PAGES INCLUDING THIS ONE--> <div class="structure clearfix"> <h1 class="title_header"> Sign In </h1> <div id="signin_form"> <?php echo validation_errors(); echo form_open('auth/validate_credentials'); echo "<div class='form_text_signin'>"; echo "Email"; echo "</div>"; echo form_input('email'); echo "<div class='form_text_signin'>"; echo "Password"; echo "</div>"; echo form_input('password'); echo form_submit('submit', 'Submit'); echo form_close(); ?> </div> </div> Controller: <?php class Auth extends CI_Controller { // this is automatically called if no other function is called // it simply turns around and calls the login() function to show the login page public function index() { $this->login(); } public function login() { $data['main_content'] = 'auth/login'; $this->load->view('includes/templates/main_page_template', $data); } function validate_credentials () { $query = $this->load->model('user_model'); if($query) { $data = array( 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'is_logged_in' => true ); $this->session->set_userdata($data); redirect('account/dashboard'); } else { $this->index(); } } }
  10. ok so to be clear here: your saying I should get rid of the validate_credentials() function currently in my controller and put : <?php $data = array( 'email' => $this->input->post('email'), 'password' => sha1($this->input->post('password'), ); $this->model_name->login($data); inside the login () function with what is already existing? With that being said. This is what I currently have trying to adapt it to your suggestions. MODEL: <?php class User_model extends CI_Model { function login($data = array()) { // validate data if( !empty($data) ) return FALSE; // retrieve query $query = $this->db ->from('users') ->where($data) ->get(); // Check if query row exists if($query->row()) { // Query row exists, return query row return $query->row(); } else { // Query row doesn't exist, return FALSE return FALSE; } CONTROLLER: <?php class Auth extends CI_Controller { // this is automatically called if no other function is called // it simply turns around and calls the login() function to show the login page public function index() { $this->login(); } public function login() { $data['main_content'] = 'auth/login'; $this->load->view('includes/templates/main_page_template', $data); } function validate_credentials () { $this->load->model('user_model'); $this->user_model->validate(); if($query) { $data = array( 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'is_logged_in' => true ); $this->session->set_userdata($data); redirect('account/dashboard'); } else { $this->index(); } } } Sorry this is so difficult. I am just very new at this MVC framework. Thanks!
  11. also more information from my error logs: mysql portion ( apache portion listed above) 120709 08:35:59 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql 120709 8:35:59 [Warning] The syntax '--skip-locking' is deprecated and will be removed in a future release. Please use --skip-external-locking instead. 120709 8:35:59 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql/ is case insensitive 120709 8:35:59 [Note] Plugin 'FEDERATED' is disabled. 120709 8:35:59 [Note] Plugin 'ndbcluster' is disabled. 120709 8:36:03 InnoDB: Started; log sequence number 0 44273 120709 8:36:03 [Note] Event Scheduler: Loaded 0 events 120709 8:36:03 [Note] /Applications/MAMP/Library/libexec/mysqld: ready for connections. Version: '5.1.44' socket: '/Applications/MAMP/tmp/mysql/mysql.sock' port: 3306 Source distribution
  12. thanks for the help. This is the error I got from your suggestions Call to undefined method User_model::validate() in /Users/michaelsanger/Sites/CodeIgniter/application/controllers/auth.php on line 20 Here is how the whole package looks according to your adjustments: MODEL: <?php class User_model extends CI_Model { function login($data = array()) { // validate data if( !empty($data) ) return FALSE; // retrieve query $query = $this->db ->from('users') ->where($data) ->get(); // Check if query row exists if($query->row()) { return true; } } } CONTROLLER: <?php class Auth extends CI_Controller { // this is automatically called if no other function is called // it simply turns around and calls the login() function to show the login page public function index() { $this->login(); } public function login() { $data['main_content'] = 'auth/login'; $this->load->view('includes/templates/main_page_template', $data); } function validate_credentials () { $this->load->model('user_model'); $query = $this->user_model->validate(); if($query) { $data = array( 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), ); $this->user_model->login($data); redirect('account/dashboard'); } else { $this->index(); } } }
  13. *edit* in my model I got rid of $query = before $this->db->where('email', $this->input->post('email'));$this->db->where('password', sha1($this->input->post('password')));
  14. Ok - I went ahead and simplified my approach back to the original way I had it based off of a code igniter tutorial video I watched. I have set the log threshhold to 4 and have scoured through all the different ways to view the error logs and am not seeing any relavent clues. Here is what the log is telling me: Please note that I reload the page and after trying to submit the form and the same results keep coming up in the log. Nothing new. [Mon Jul 09 08:36:11 2012] [notice] Digest: generating secret for digest authentication ... [Mon Jul 09 08:36:11 2012] [notice] Digest: done [Mon Jul 09 08:36:11 2012] [notice] Apache configured -- resuming normal operations ( note that these are from yesterday and not this morning ) Here is the simplified MVC I've reverted back to. I will go through the view later and simplify the html, as I have to work it to my styles and am more concerned with resolving the major issue at hand first. MODEL: <?php class User_model extends CI_Model { function validate () { $query = $this->db->where('email', $this->input->post('email')); $query = $this->db->where('password', sha1($this->input->post('password'))); $query = $this->db->get('users'); if($query->num_rows == 1) { return true; } } } VIEW: <title>Login</title> <!--MAKE SURE SIGNED OUT HEADER IS IMPLEMENTED FOR ALL SIGNED OUT PAGES INCLUDING THIS ONE--> <div class="structure clearfix"> <h1 class="title_header"> Sign In </h1> <div id="signin_form"> <?php echo validation_errors(); echo form_open('auth/validate_credentials'); echo "<div class='form_text_signin'>"; echo "Email"; echo "</div>"; echo form_input('email'); echo "<div class='form_text_signin'>"; echo "Password"; echo "</div>"; echo form_input('password'); echo form_submit('submit', 'Submit'); echo form_close(); ?> </div> </div> CONTROLLER: <?php class Auth extends CI_Controller { // this is automatically called if no other function is called // it simply turns around and calls the login() function to show the login page public function index() { $this->login(); } public function login() { $data['main_content'] = 'auth/login'; $this->load->view('includes/templates/main_page_template', $data); } function validate_credentials () { $this->load->model('user_model'); $this->user_model->validate(); if($query) { $data = array( 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), 'is_logged_in' => true ); $this->session->set_userdata($data); redirect('account/dashboard'); } else { $this->index(); } } }
  15. Hello - I am fairly new to codeigniter, and it's been about a week now being stuck with this error. I have watched video tutorials, read copious amounts of related questions on other forums, and tried about 10 different methods and continue to get this error. I have hit a wall and really need help. I've tried loading the my database manually and with the auto-helper as well as trouble shooting my config files and such. please help! Here is my current MVC set up for trying to login a user: MODEL: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class User_model extends CI_Model { function __construct(){ parent::__construct(); } public function validate(){ // grab user input $email = $this->security->xss_clean($this->input->post('email')); $password = $this->security->xss_clean($this->input->post('password')); // Prep the query $this->db->where('email', $email); $this->db->where('password', $password); // Run the query $query = $this->db->get('users'); // Let's check if there are any results if($query->num_rows == 1) { // If there is a user, then create session data $row = $query->row(); $data = array( 'id' => $row->id, 'first_name' => $row->first_name, 'last_name' => $row->last_name, 'validated' => true ); $this->session->set_userdata($data); return true; } // If the previous process did not validate // then return false. return false; } } ?> VIEW: <title>Login</title> <!--MAKE SURE SIGNED OUT HEADER IS IMPLEMENTED FOR ALL SIGNED OUT PAGES INCLUDING THIS ONE--> <div class="structure clearfix"> <h1 class="title_header"> Sign In </h1> <div id="signin_form"> <?php echo validation_errors(); echo form_open('auth/process'); echo "<div class='form_text_signin'>"; echo "Email"; echo "</div>"; echo form_input('email'); echo "<div class='form_text_signin'>"; echo "Password"; echo "</div>"; echo form_input('password'); echo form_submit('submit', 'Submit'); echo form_close(); ?> </div> </div> CONTROLLER: <?php class Auth extends CI_Controller { // this is automatically called if no other function is called // it simply turns around and calls the login() function to show the login page public function index($msg = NULL) { $data['msg'] = $msg; $this->login(); } function __construct() { parent::__construct(); } public function login() { $data['main_content'] = 'auth/login'; $this->load->view('includes/templates/main_page_template', $data); } public function process(){ // Load the model $this->load->model('user_model'); // Validate the user can login $result = $this->user_model->validate(); // Now we verify the result if(! $result){ // If user did not validate, then show them login page again $this->index(); }else{ // If user did validate, // Send them to members area redirect('account/dashboard'); } } } thanks so much in advance
  16. I'm actually going to read into creating class libraries so if I have trouble after that I'll repsond. thanks for al your help so far!
  17. as I'm new with these concepts, I could be missing it, but I didn't see any relationships to my code and the error scripts. I also looked in the errors section of the config.php file and could see anything there
  18. So your saying I have to create the $user->logged_in() somewhere before.
  19. I see and understand that, but am not at all understanding why it's posing an error. None the less an error very close to the one that originally got me to post this thread.
  20. First off...thanks so much for the help I tried to adapt your model and controller to mine and am getting this error: Call to a member function logged_in() on a non-object in /Users/my_computer/Sites/CodeIgniter/application/controllers/auth.php on line 16 Here is my controller post adaptation: <?php class Auth extends CI_Controller { // this is automatically called if no other function is called // it simply turns around and calls the login() function to show the login page public function index() { $this->login(); } function login() { // Check to see if the user is logged in if ($this->user->logged_in()) { // User is logged in, redirect them redirect('dashboard'); } // Retrieve login submit from account/login $login = $this->input->post('login'); // Login comes from navbar if( !$login ) { // Retrieve the forms $redirect = $this->input->post('redirect'); // Set form validation rules $this->form_validation->set_rules('email', 'Email', 'trim|required|callback__check_login'); $this->form_validation->set_rules('password', 'Password', 'trim|required'); // Check for timeout if( $this->session->userdata('timeout') ) $this->form_validation->set_rules('captcha', 'Image Verification', 'trim|required|callback__check_captcha'); // Form validation passed, so continue if (!$this->form_validation->run() == FALSE) { // Login the user if(!$this->user->login($this->input->post('email'), $this->input->post('password'), $this->input->post('remember'))) { // Login failed, alert the user $this->form_validation->set_message('login_failed', 'Invalid credentials'); } else { // Redirect the user redirect($redirect); } } // Load the login view $this->load->view('auth/login'); } function __construct() { parent::__construct(); $this->load->model('user_model'); } } }
  21. I'm not sure what you mean? Can you please be more detailed if possible? thanks for the help
  22. I realize that is where the issue is, I'm just clueless apparently on how to fix it!!!
  23. trust me, I have been the whole time for the most part. I've tried: parent::__construct(); $this->load->database('cysticlife_CI'); parent::__construct(); $db = $this->load->database(); to name a couple
  24. Yeah guy's I'm stuck. I've tried so many different things and am just clueless as to why it's STILL posing this error. For some reason it's not connecting to my db. This is what I currently have for the model ( which is the page posing the error and disabling the page from running the validate_credentials function <?php class User_model extends CI_Model { public function __construct() { parent::__construct(); $this->load->database(); } function validate () { $this->db->select('*'); $this->db->from('users'); $this->db->where('email', $this->input->post('email')); $this->db->where('password', sha1($this->input->post('password'))); $validate_user = $this->db->get(); if($validate_user->num_rows == 1) { return TRUE; } } }
  25. Yeah that's what seems to be the issue,however I have tried loading it manually and with the autohelper function and it's still posing that error. Do you happen to have another suggestion or is there something I am blatantly missing?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.