Welcome Guest, Not a member yet? Register   Sign In
Setting up a default username and password
#1

I have a small web application designed for a small business where the users are only 2 but with different user privilege.
My idea is after the user logged in using the default user and password he will be redirected to a page where he will be updating his password and username. If the user will not update it then it will not be able to navigate through admin dashboard.

Here's my code:


Code:
class User_model extends Base_model
{
    public function __construct()
    {
        parent:: __construct();
        $this->user_add();
    }

    public function user_add()
    {
        if ($rows = $this->count_row() < 2) {
            $data = array(
                array(
                    "user_username" => "admin",
                    "user_userpass" => "default",
                    "user_type" => "admin"
                ),
                array(
                    "user_username" => "normal",
                    "user_userpass" => "default",
                    "user_type" => "standard"
                ),
            );

            for ($i = 0; $i < 2; $i++) {
                $this->add('user', $data[$i]);
            }
            return true;
        }
        return;
    }

    public function count_row()
    {
        $result = $this->db->count_all('user');
        return $result;
    }

Would these be a good practice or shall I only asked username for first-time logged in
Reply


Messages In This Thread
Setting up a default username and password - by nullstrike - 07-13-2017, 08:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB