Welcome Guest, Not a member yet? Register   Sign In
set_value from $_POST array, No Validation

Hey guys,

I am trying to set to get my form to re-populate after I click the submit button.
I am not using the validation library.

Basically, what I want to happen is that there is a default value in the 'name' textbox when the page is loaded first, then when a user enters a new value in the textbox and submits the form, this value is remembered...

Does anyone have any ideas?

function test_validation() {
    $test_form = form_open(current_url());
        $test_form .= form_label('Name', 'name') . form_input('name', set_value('name as','default value'));
        $test_form .= form_label('Email Address', 'email_address') . form_input('email_address', '[email protected]');
        $test_form .= form_submit('submit_btn', 'Submit');
    $test_form .=form_close();
    echo $test_form;
    //Form posted back
    if( $this->input->post('submit_btn') ) {
        echo 'The form was posted back.<br />';
        foreach (($_POST) as $key => $value) {
            echo "$key:$value<br />";




set_value() is usually used in a view, and it accepts two parameters. The field name, and the default value, not a key and a value.

Use the form validation library.

Theme © iAndrew 2016 - Forum software by © MyBB