Welcome Guest, Not a member yet? Register   Sign In
POST and anchor problem
#1

[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>&lt;?php echo form_input('customer_name', '');; ?&gt;</td>
                </tr>            
            
            </table>            

&lt;?php echo form_close();?&gt;
&lt;?php $this->load->view("footer"); ?&gt;

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


Messages In This Thread
POST and anchor problem - by El Forum - 11-26-2007, 05:42 AM
POST and anchor problem - by El Forum - 11-26-2007, 06:57 AM
POST and anchor problem - by El Forum - 11-26-2007, 10:36 AM
POST and anchor problem - by El Forum - 11-26-2007, 11:17 AM
POST and anchor problem - by El Forum - 11-26-2007, 11:25 AM
POST and anchor problem - by El Forum - 11-26-2007, 07:28 PM
POST and anchor problem - by El Forum - 11-26-2007, 09:01 PM
POST and anchor problem - by El Forum - 11-26-2007, 09:17 PM
POST and anchor problem - by El Forum - 11-26-2007, 09:24 PM
POST and anchor problem - by El Forum - 11-26-2007, 09:26 PM
POST and anchor problem - by El Forum - 11-26-2007, 09:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB