I am a beginner codeigniter. My purpose is get value from form of example_view.php view, then display this result in the result.php view, when i submitted.
- how can i correct this problem?
- If i want to pass this value into session, how can i do?
example_view.php(view)
<html>
<head><title>Test Example View</title></head>
<body>
<h1 align="center">Test Sample CI Framwork</h1>
<?php echo form_open('example/getvalue'); ?>
<input type="text" name="username" value="" size="50" />
<div><input type="submit" value="Submit" name="submit"/></div>
<?php echo form_close(); ?>
</body>
</html>
result.php(view)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php echo 'Your new value is '.$value;?>
</body>
</html>
example.php(controller)
<?php
class Example extends Controller {
function Example()
{
parent::Controller();
$this->load->helper('form');
$this->load->helper('url');
}
function index() {
$this->load->view('example_view');
$this->getvalue();
}
function getvalue()
{
if ($this->input->post('submit')==true) {
$data['value']=$this->input->post('username');
$this->load->view('result',$data);
}
}
}
?>
Thank for your help.