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

  • Home
  • SEARCH
  • 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 8774981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:41:59+00:00 2026-06-13T18:41:59+00:00

I have codeigniter model like this <?php class Model_Login extends CI_Model{ function __construct(){ parent::__construct();

  • 0

I have codeigniter model like this

<?php

class Model_Login extends CI_Model{
    function __construct(){
        parent::__construct();
    }

    public function login_submit($arrayData){
        extract($arrayData);
        $username=clean($txtusername);
        $password=clean($txtpassword);

        //first get salt for the respective user.
        $getsalt=$this->db->query("SELECT PASSWORD_SALT FROM USER_INFOS WHERE USER_NNAME=?",array($username))->row();
        $salt=$getsalt->PASSWORD_SALT;
        $password=sha1($salt.$password);

        $query=$this->db->query("SELECT * FROM USER_INFOS WHERE STATUS='Y' AND USER_NNAME=? AND USER_PASSWORD=?",array($username,$password));

        if($query->num_rows>0){
            $row=$query->row();
            // login successfull create session
            $this->session->set_userdata('USER_ID', $row->USER_ID);
            $this->session->set_userdata('USER_FULL_NAME', $row->USER_ENAME);

            return "success";
        }else{
            return "Invalid username and/or password.";
        }





    }
}

?>

Where,
PASSWORD_SALT, is a database field that contains 128 character long random(for each user) salt hashed using hash function.

The code works perfect if USERNAME is unique. But i m trying to think of the client who may ask that username should not be unique. If username is not unique it always select first row and all except one having same username will not be able to login even they provide valid username and password.

What will be better work around on this scenario?

EDIT

I know Putting USERNAME not unique is a bad idea. But in our country there are several websites where username is not unique (or in some case username is even predictable). For example, I have an account in certain branch of bank whose branch code is 032, and my name is John Smith, then the username to access their ebanking will be 032JOHNS, there might be more than one John Smith in that branch finally having same username. And to login to their ebanking system i just need to provide this username and my password.

Thanks

  • 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-06-13T18:42:00+00:00Added an answer on June 13, 2026 at 6:42 pm

    If the username is not unique, then what uniquely identifies the user?

    It has to be something the user provides at login, and it can’t be a combination of username and password, because there’s certainly no guarantee that two users won’t pick the same password.

    So if the username is not unique, then something else has to be unique (or be unique in combination with the username). For example, if they’re doing some kind of multi-tenant by custom domains, then it would be the domain.

    But you can’t have non-unique usernames and expect the password to determine the correct user.

    (Side note, well you can, but you shouldn’t – I happen to be able to login into two different Amazon accounts using the same email address, but different passwords. I wonder what would happen if I changed one password to match the other, but I value my account too much to try it.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method in codeigniter that looks like this, public function category() {
I'm trying to use PHP ActiveRecord in Codeigniter. I have a model like this:
I have a callback function for CURLOPT_PROGRESSFUNCTION in codeigniter like below: class download_model extends
Right now I have something like this in my CodeIgniter model: <?php $array =
I'm using CodeIgniter and I have a PHP MySQL Statement in a model: function
I have a model function that updates a user in my CodeIgniter application: //
I have this function in a Code Igniter model that creates a new video.
I have a CI Model set up with this function and ActiveRecord: function get_open_competitions()
i have a controller like this one : <?php if( ! defined('BASEPATH')) exit ('No
Using PHP, If I have a model (a class) where I various queries, whatever

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.