Search
 
SCRIPT & CODE EXAMPLE
 

PHP

CODEIGNITER codeigniter 4 auth

<?php

namespace AppControllers;

use AppmodelsUsers_model;

class Signin extends BaseController {

    public function index() {
        return view('signin/index');
    }

    public function authenticate() {
        if ($this->exists($_POST['email'], $_POST['password']) != NULL) {
            $session = session();
            $session->set('email', $_POST['email']);
            return $this->response->redirect(site_url('signin/profile'));
        } else {
            $data['msg'] = 'wrong';
            return view('signin', $data);
        }
    }

    public function profile() {
        return view('signin/profile');
    }

    private function exists($email, $password) {
        $model = new Users_model();
        $account = $model->where('email', $email)->first();
        if ($account != NULL) {
            if (password_verify($password, $account['password'])) {
                return $account;
            }
        }
        return NULL;
    }

}
Comment

CODEIGNITER codeigniter 4 auth

<?php

namespace Appmodels;

use CodeIgniterModel;

class Users_model extends Model {

    protected $table = 'users';
    protected $primaryKey = 'id';
    protected $allowedFields = ['first_name', 'last_name', 'email', 'password'];

}
Comment

PREVIOUS NEXT
Code Example
Php :: php unit test 
Php :: php += 
Php :: laravel get next and previous record 
Php :: get ids from object 
Php :: php barcode generator 
Php :: create model for existing table in laravel 
Php :: Laravel whereHas with count 
Php :: laravel mass update relationship 
Php :: laravel relationship retrieve data 
Php :: Creating dynamic subdomain in php 
Php :: publish spatie/permission 
Php :: base64_img 
Php :: function to find the mod of a number in php 
Php :: date comparison function in php 
Php :: php DateTime only date 
Php :: what is the use of closure function in php 
Php :: public $baseURL codeigniter 4 
Php :: laravel project composer [ErrorException] Undefined index: name 
Php :: relationship in laravel 
Php :: php backend generator 
Php :: get firstwod php 
Php :: laravel find 
Php :: laravel set middleware default 
Php :: PHP Notice: Trying to get property of non-object 
Php :: Add Custom Field to woocommerce Subscriptions 
Php :: php how to check if user has a role on login 
Php :: google sheets to php equation 
Php :: how to get keys of associative array php 
Php :: laravel set innodb scema builder 
Php :: get server name php 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =