Advertisement
Guest User

Controlador

a guest
Nov 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. /**
  4. * @author ralf
  5. * @desc Clase IMC que contiene los calculos aritmeticos
  6. * **/
  7. class Imc extends CI_Controller{
  8.  
  9. public function __construct(){
  10. parent::__construct();
  11. $this->load->model('imc_model');
  12. $this->load->helper(array('url','language'));
  13. }
  14.  
  15. public function index(){
  16. //https://pastebin.com/xfhPyQ63
  17. $this->load->helper(array('form', 'url'));
  18. $this->load->library('form_validation');
  19. //
  20. $this->form_validation->set_error_delimiters('<div class="alert alert-danger">', '</div>');
  21. $this->form_validation->set_rules('peso', 'Peso', 'required|trim|max_length[3]|integer');
  22. $this->form_validation->set_rules('estatura', 'Estatura', 'required|trim|max_length[3]|integer');
  23. //
  24. if ($this->form_validation->run() == FALSE){
  25. $this->load->view("imc_view");
  26. }else{
  27. //TRUE del formulario
  28. $datos['calculo'] = $this->input->post('peso') / ($this->input->post('estatura') * $this->input->post('estatura'));
  29. $this->imc_model->insertar($datos);
  30. $this->load->view("imc_view", $datos);
  31.  
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement