Welcome Guest, Not a member yet? Register   Sign In
Please explain how to use forms/posting data
#1

[eluser]solepixel[/eluser]
I am having the hardest time using forms to perform the simplest of operations:

using the code:
Code:
$formAttr = array('id' => 'new_account');
echo form_open(uri_string(), $formAttr);
    echo form_fieldset('Personal Information');
    $input = array(
        'name' => 'f_name',
        'id' => 'f_name',
        'value' => set_value('f_name'),
        'class' => 'text'
    );
    
    echo form_label('First Name','f_name');
    echo form_input($input);
    echo form_submit('submit', 'Submit', 'id="submit_btn"');

    echo form_fieldset_close();

echo form_close();

for some reason, using set_value() is still not retaining my post values. It's almost as if my page is doing a redirect after form variables are being submit. If i try to refresh after a POST, i do not get the dialog "Are you sure you want to resend post data.. blah blah blah".

The only way i could get it to work is to post from /onepage/ to /onepage/?withquery and that would retain my post variables. however posting from /onepage/?withquery to /onepage/?withquery causes the same issue as before and loses post variables.

Any ideas what is going on here?
#2

[eluser]solepixel[/eluser]
Ok. so I've narrowed down the problem.

In my .htaccess file, i'm adding a '/' to the end of the URL if it does not already end in a '/' or '.[ext]'.
here's that code:
Code:
# If requested resource does not exist as a file
    RewriteCond %{REQUEST_FILENAME} !-f
    # and does not end with a period followed by a filetype
    RewriteCond %{REQUEST_URI} !\..+$
    # and does not end with a slash
    RewriteCond %{REQUEST_URI} !/$
    # then add a trailing slash and redirect
        RewriteRule (.*) $1/ [R=301,L]

well, this poses a problem when using form_open() + uri_string() because it automatically converts your action attribute to the FULL URL of the site (which is a bit rediculous). Somewhere during that process, the uri loses the '/'.

So to solve this issue, in the config file, I changed this:
Code:
$config['url_suffix'] = "/";

I guess now I want to know why CodeIgniter uses the FULL SITE URL (http://blahblah/) on all functions like form_open() and anchor() etc. Also, why haven't they provided an option to disable this feature. It seems a bit useless. Why not just use '/' in place of 'http://garbledgoop/'. If it's not useless, i'd really like to know why it's done that way.
#3

[eluser]CroNiX[/eluser]
set_value() is part of the validation library, are you using it in your controller? Post your controller.




Theme © iAndrew 2016 - Forum software by © MyBB