working with forms in codeigniter
Before we work with forms, we need to add form option in helper on autoload.php file as follows:
After changing this, create the following file as login.php in views
$autoload['helper'] = array('url', 'file','form');
After changing this, create the following file as login.php in views
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<div class="container" style="margin-top:30vh;">
<div class="row">
<div class="col-lg-4 col-md-4 col-sg-oush-4 col-md-push-4">
<div class="panel panel-default">
<div class="panel-heading">LOGIN</div>
<div class="panel-body">
<?php echo form_open('url'); ?>
<div class="form-group">
<input type="text" name="u_name" placeholder="Username" required class="form-control input-sm">
</div>
<div class="form-group">
<input type="password" name="u_password" placeholder="Password" required class="form-control input-sm">
</div>
<div class="form-group">
<input type="submit" name="u_login" value="Login" class="btn btn-success btn-sm">
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
</div>
</div>
Note that, here i used bootstrap so don't forgot to add header and footer file in the controller. Here is my controller.
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Home extends CI_Controller
{
public function index()
{
$this->load->view("home");
}
public function login()
{
$this->load->view("header");
$this->load->view("login");
$this->load->view("footer");
}
}
⇐Prev
Next⇒
Comments
Post a Comment