creating a user registration form in codeigniter

For creating user registration in login page, I added the following code in the home controller :

  public function register()
  {
    $this->load->view("header");
    $this->load->view("register");
    $this->load->view("footer");
  }

Then just copy & paste the login page to the register page and add email input and a new button so we get 2 buttons as login and register.

register.php

<?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">REGISTER</div>
               <div class="panel-body">
                  <?php echo form_open('register'); ?>
                     <div class="form-group">
                        <input type="email" name="u_email" placeholder="Email" required class="form-control input-sm">
                     </div>
                     <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="Register" class="btn btn-success btn-sm">
                        <a href="<?php echo site_url('login'); ?>" class="btn btn-warning btn-sm">Login</a>
                     </div>
                  <?php echo form_close(); ?>
               </div>
         </div>
      </div>
  </div>
</div>

Here I also added a link to the login page so you can easly switch to login page. Don't forget to add a link in login page linking to register page for switching between them.



Prev
Next

Comments

Popular posts from this blog

Node.js Cheat Sheet

Codeigniter ! Simple But Powerful

Bootstrap ? What is it ?