Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:47+00:00 2026-05-26T14:29:47+00:00

here is the controller to login form, after the login process the user will

  • 0

here is the controller to login form, after the login process the user will be able to do add posts to database, so i need to collect some data as the username of the current logged user & the id of this user in the {users table}

<?php

class login extends CI_Controller{
function index()
{
    $this->load->view('login_form');
}
function proccess()
{
    $this->load->model('membership_model');
    $query = $this->membership_model->validate();

    if($query) // if the user's credentials validated ..
    {
        $data = array(
            'username_usr' => $this->input->post('username'),
            'is_logged_in' => true
        );
        $this->session->set_userdata($data);

        redirect('view=dogo&do=new_post');
    }
    else 
    {
        $this->index();
    }
}

function signup()
{
    //signup proccess
}
}

and here is the model of login process

<?php
class Membership_model extends CI_Model{
function validate()
{
    $this->db->where('username_usr', $this->input->post('username'));
    $this->db->where('password_usr', md5($this->input->post('password')));
    $query = $this->db->get('hs_users_usr');

    if($query->num_rows == 1)
    {
        return true;
    }
}
}

I can return the username of the logged user, i need also to return the id of this user

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:29:47+00:00Added an answer on May 26, 2026 at 2:29 pm

    You can return the query if it’s successful and pull the user id from it:

    Controller

    <?php
    
    class login extends CI_Controller{
    function index()
    {
        $this->load->view('login_form');
    }
    function proccess()
    {
        $this->load->model('membership_model');
        $query = $this->membership_model->validate();
    
        if($query !== FALSE) // if the user's credentials validated ..
        {
            $user_data = $query->row();
    
            $data = array(
                'user_id' => $user_data->id,
                'username_usr' => $this->input->post('username'),
                'is_logged_in' => true
            );
    
            $this->session->set_userdata($data);
    
            redirect('view=dogo&do=new_post');
        }
        else 
        {
            $this->index();
        }
    }
    
    function signup()
    {
        //signup proccess
    }
    }
    

    Model

    <?php
    class Membership_model extends CI_Model{
    function validate()
    {
        $this->db->where('username_usr', $this->input->post('username'));
        $this->db->where('password_usr', md5($this->input->post('password')));
        $query = $this->db->get('hs_users_usr');
    
        if($query->num_rows == 1)
        {
            return $query;
        }
        else
        {
            return FALSE;
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the idea: When the user wants to see /controller/action, then I want
After a new user submits a 'New account' form, I want to manually log
I'm creating a login form with Codeigniter, and I have a controller that collects
I'm working on a simple login form. When the user clicks on the Login
So I am creating a form builder. Users will login and then fillout the
I have a login form from which the user enters user name and password.
Here is my code: ThreadStart threadStart = controller.OpenFile; Thread thread = new Thread(threadStart); thread.Start();
Here is the first part of my controller code: public class ControlMController : Controller
here the following code is used to view the present modal view controller. [[self
I'm struggling here with a problem: I have a controller questions which has action

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.