In this article we will learn about some of the frequently asked Php programming questions in technical like “CODEIGNITER codeigniter 4 auth” Code Answer’s. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error handling in PHP is simple. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in PHP. Below are some solution about “CODEIGNITER codeigniter 4 auth” Code Answer’s.
CODEIGNITER codeigniter 4 auth
xxxxxxxxxx
1
<?php
2
3
namespace Appmodels;
4
5
use CodeIgniterModel;
6
7
class Users_model extends Model {
8
9
protected $table = 'users';
10
protected $primaryKey = 'id';
11
protected $allowedFields = ['first_name', 'last_name', 'email', 'password'];
12
13
}
14
CODEIGNITER codeigniter 4 auth
xxxxxxxxxx
1
<?php
2
3
namespace AppControllers;
4
5
use AppmodelsUsers_model;
6
7
class Signin extends BaseController {
8
9
public function index() {
10
return view('signin/index');
11
}
12
13
public function authenticate() {
14
if ($this->exists($_POST['email'], $_POST['password']) != NULL) {
15
$session = session();
16
$session->set('email', $_POST['email']);
17
return $this->response->redirect(site_url('signin/profile'));
18
} else {
19
$data['msg'] = 'wrong';
20
return view('signin', $data);
21
}
22
}
23
24
public function profile() {
25
return view('signin/profile');
26
}
27
28
private function exists($email, $password) {
29
$model = new Users_model();
30
$account = $model->where('email', $email)->first();
31
if ($account != NULL) {
32
if (password_verify($password, $account['password'])) {
33
return $account;
34
}
35
}
36
return NULL;
37
}
38
39
}
40