Skip to Content
PHPCODE
Codeigniter Create Login Form
codeigniter code / July 28, 2018

Create Login Form in Codeigniter

step 1 :- First One Created Form user Boostrap class

(1) public folder Created in view

(2) public file created public_header.php

<!DOCTYPE html>
<html>
<head>
<title>Article List</title>
<!– <link rel=”stylesheet” type=”text/css” href=”http://localhost/project_codeigniter/assets/css/bootstrap.min.css”> –>
<!– <link rel=”stylesheet” type=”text/css” href=”<?php // echo base_url’assets/css/bootstrap.min.css);?>”> –>
<?= link_tag(‘assets/css/bootstrap.min.css’);?>
</head>
<body>
<nav class=”navbar navbar-expand-lg navbar-dark bg-primary”>
<a class=”navbar-brand” href=”#”>Articles</a>
<button class=”navbar-toggler” type=”button” data-toggle=”collapse” data-target=”#navbarColor01″ aria-controls=”navbarColor01″ aria-expanded=”false” aria-label=”Toggle navigation”>
<span class=”navbar-toggler-icon”></span>
</button>

<div class=”collapse navbar-collapse” id=”navbarColor01″>
<ul class=”navbar-nav mr-auto”>
<li class=”nav-item active”>
<a class=”nav-link” href=”#”>Login<span class=”sr-only”>(current)</span></a>
</li>
</ul>
<form class=”form-inline my-2 my-lg-0″>
<input class=”form-control mr-sm-2″ type=”text” placeholder=”Search”>
<button class=”btn btn-secondary my-2 my-sm-0″ type=”submit”>Search</button>
</form>
</div>
</nav>

(2) public file created public_footer.php

<script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js”></script>
<script src=”<?= base_url(‘assets/js/bootstrap.min.js’);?>”></script>
</body>
</html>
(3) public file created admin_login.php

<?php include(‘public_header.php’);?>

<div class=”container”>
<form method=”post” action=”<?= base_url(‘login/admin_login’);?>”>
<fieldset>
<legend>Admin Login</legend>
<div class=”form-group”>
<label for=”exampleInputEmail1″>User Name</label>
<input type=”text” class=”form-control” id=”exampleInputEmail1″ aria-describedby=”emailHelp” placeholder=”User Name”>
</div>
<div class=”form-group”>
<label for=”exampleInputPassword1″>Password</label>
<input type=”password” class=”form-control” id=”exampleInputPassword1″ placeholder=”Password”>
</div>
<button type=”submit” class=”btn btn-primary”>Submit</button>
<button type=”reset” class=”btn btn-default”>Cancel</button>
</fieldset>
</form>
</div>

<?php include(‘public_footer.php’);?>

step 2 :- First One Created Form user Boostrap class and codegniter in
helper

<?php include(‘public_header.php’);?>

<div class=”container”>
<?php echo form_open(‘login/admin_login’);?>
<fieldset>
<legend>Admin Login</legend>
<div class=”form-group”>
<?php
echo form_label(‘User Name’);
echo form_input([‘class’=>’form-control’,’name’=>’username’,’placeholder’=>’User Name’]);
?>
</div>
<div class=”form-group”>
<?php
echo form_label(‘Password’);
echo form_password([‘class’=>’form-control’,’name’=>’password’,’placeholder’=>’Password’]);
?>
</div>
    <?php
echo form_submit([‘class’=>’btn btn-primary’,’value’=>’LOGIN’]),
form_reset([‘class’=>’btn btn-default’,’value’=>’RESET’]);
?>
</fieldset>
<?php echo form_close();?>
</div>

<?php include(‘public_footer.php’);?>

PHPCODE © 2024