[eluser]cinewbie81[/eluser]
Hi all,
I have a question regarding POST function and anchor function.
The following is my "test" controller class:
Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Test extends Controller {
function Test()
{
// Load neccessary helper file, library etc
parent::Controller();
$this->load->helper(array('url','form'));
}
function index()
{
$this->load->view('home/home_test_view', $data);
}
function verification()
{
if ($this->input->post('save_y')) {
echo $this->input->post('customer_name');
}
}
}
?>
and my "test" view page:
Code:
<?php $this->load->view("header"); ?>
<?php echo form_open('test/verification');?>
<input type="image" name="send" src="<?php echo base_url();?>images/save.gif" value="Save" alt="Save" title="Save">
<table border="0" height="100%" id="tablesetting">
<tr>
<td>Name:</td>
<td><?php echo form_input('customer_name', '');; ?></td>
</tr>
</table>
<?php echo form_close();?>
<?php $this->load->view("footer"); ?>
According to the code above, when i type something - let's say 'John' into
customer_name input and press 'F5' to refresh the page, the value for
customer_name input still remain 'John' . I want to set the value to original state - which is blank.
Then i found out that it's because of the form_open and form_close in my code. Comment out these two statement will get the
customer_name input become blank after refresh.
Anyway, if i comment out form_open and form_close, how am i going to pass the 'customer_name' value to the controller class when i click at the 'save' button ?? I know it can be solved by using "anchor('test/verification/
customer_name', 'Save')" instead of using "button", but i dont want it to be this way because it make my url looks like so complicated. Anyone help ? Thanks