login in codeigniter code example
Example 1: codeigniter 4 login example
<?php namespace App\Controllers;
use CodeIgniter\Controller;
class Home extends Controller
{
public function index()
{
return view('welcome_message');
}
}
Example 2: codeigniter 4 login example
<html>
<head></head>
<body>
<div class="wrap">
<?php echo $content; ?>
</div>
</body>
</html>
Example 3: codeigniter 4 login example
<?php
if ( ! function_exists('render'))
{
function render(string $name, array $data = [], array $options = [])
{
return view(
'layout',
[
'content' => view($name, $data, $options),
],
$options
);
}
}
Example 4: codeigniter 4 login example
<?php namespace App\Controllers;
use CodeIgniter\Controller;
class Home extends Controller
{
public function index()
{
return render('welcome_message');
}
}
Example 5: codeigniter login system with session
<!DOCTYPE html>
<html>
<head>
<title>Webslesson | <?php echo $title; ?></title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<br /><br /><br />
<form method="post" action="<?php echo base_url(); ?>main/login_validation">
<div class="form-group">
<label>Enter Username</label>
<input type="text" name="username" class="form-control" />
<span class="text-danger"><?php echo form_error('username'); ?
></span>
</div>
<div class="form-group">
<label>Enter Password</label>
<input type="password" name="password" class="form-control" />
<span class="text-danger"><?php echo form_error('password'); ?
></span>
</div>
<div class="form-group">
<input type="submit" name="insert" value="Login" class="btn btn-info" />
<?php
echo '<label class="text-danger">'.$this->session->flashdata
("error").'</label>';
?>
</div>
</form>
</div>
</body>
</html>
Example 6: codeigniter 4 login example
<?php namespace Config;
use CodeIgniter\Events\Events;
Events::on('post_controller_constructor', function() {
helper('render');
});