CodeIgniter BMI计算器不工作[重复]

I have been using Codeigniter for an assignment in university and I cannot seem to get this to work, any feedback and fixes are greatly appreciated. The errors returned are:

  • Undefined index: submit
  • Undefined variable: weight
  • Undefined variable: height
  • Division by zero

This is the code that doesnt work, it is a file in the views folder:

<div id="container">
<h1>BMI and Blood Pressure Calculator</h1>

<div id="body">
    <p>This webpage allows users to calculate their BMI and Blood Pressure by entering in their values into the boxes</p>
    </br>           
    <p>Please enter in your details below</p>

<form>
     <br />
     <br />Patient Information
     <br />Height <input type="text" name="height" size="12" maxlength="20">
     <br />Weight <input type="text" name="weight" size="12" maxlength="20">
     <br />
     <br /><input type="reset" value="Clear Form">
     <br /><input type="submit" value="Submit Information">
</form>
</div>

<?php

        $this->input->post('height');
        $this->input->post('weight');

          if ($_GET['submit']) {
          $height = $_GET['height'];
          $weight = $_GET['weight'];
        }
          function bmi($height,$weight) {
            $bmi = $weight/($height*$height);
            return $bmi;
        }

            $bmi = bmi($weight,$height);

              if ($bmi <= 15) {
                $output = "Very severely underweight";

              } else if ($bmi > 15 AND $bmi<=16 ) {
                $output = "Severely underweight";

              } else if ($bmi > 16 AND $bmi<=18.5) {
                $output = "Underweight";

              } else if ($bmi > 18.5 AND $bmi<=25) {
                $output = "Normal";

              } else if ($bmi > 25 AND $bmi<=30) {
                $output = "Overweight";

              } else if ($bmi > 30 AND $bmi<=35) {
                $output = "Obesity class 1";

              } else if ($bmi > 35 AND $num<=40) {
                $output = "Obesity class 2";

              } else if ($bmi > 60) {
                $output = "Obesity class 3";

              echo "Your BMI is " . $bmi . " and you are : ";
              echo "$output";

              }
        ?>
</div>

I don't think your view page gets to access $this->input directly unless you pass it from the controller to the view. The ideal way to do this would be

on submit of the form receive the values in the controller [ you will need to post to localhost/project_folder/Calc ]

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

class Calc extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $data['height'] = $this->input->post('height', true);
        $data['weight'] = $this->input->post('weight', true);
        $this->load->view('page_which_contains_your_logic',$data);
    }
}

Then on the page you can do the following

echo $height." ".$weight;

You should have a better look at the codeigniter documentation to see how data flows between the model, view and controllers.