Form Tag
Add of Two Number in CodeIgniter

Create Form in View Folder save this viewnumber.php

<!DOCTYPE html>

<html lang = "en">

   <head>

      <meta charset = "utf-8">

      <title>CodeIgniter Basic Example</title>

   </head>

   <body>

      <form name="frm" action="student/test" method="post">

      Enter Number1<input name="number1" type="text" value=""/><br>

      Enter Number2<input name="number2" type="text" value=""/><br>

      <?php

                  if(isset($number3))

                  echo $number3;

      ?>

      <input name="btn" type="submit" value="Submit"/>

      </form>

   </body>

</html>

 

Create Controller and save this student.php in controller folder.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Student extends CI_Controller {

                public function index()

                {

                                $this->load->view('create_student');

 

                }

                public function test()

                {

                                $number1=$this->input->post('number1');

                                $number2=$this->input->post('number2');

                                $number3=$number1+$number2;

                                $data['number3']=$number3;

                                $this->load->view('create_student',$data);

                }

}


Previous
Next