Welcome Guest, Not a member yet? Register   Sign In
Problem with some POST data
#1

[eluser]Alhazred[/eluser]
In my application all the forms use the method POST, all of them works fine but one.

I have a link on a page, this link calls a controller's function, this function only loads a page.
Inside this page there is a form
Code:
<form id='moduserdata' name='moduserdata' method='post' action='<?php echo base_url().'users/mod_pers_data_act' ?>'>
I fill the form fields, press the submit button and it calls another method of the same controller above.
The problem is that if I try to print
echo $this->input->post('nome');
or any other field, nothing appears.

The form's action is correct because if I replace the echo above with
echo "blabla";
that appears.

The POST data look to don't arrive to the method, which could be the reason?
#2

[eluser]rip_pit[/eluser]
Can you try to print with
Code:
$_POST['yourfield];
instead of
Code:
$this->input->post(‘nome’);

you'll see if the post contains data or not.

Replace the full html tag with the form_helper method
Code:
$this->load->helper('form');
echo form_open('email/send', array('class' => 'email', 'id' => 'myform'));
more at : form_helper guide

A quick way to debug posts is to enable debugger :
Code:
$this->output->enable_profiler(TRUE);

#3

[eluser]CroNiX[/eluser]
I don't think your form action is correct as you say it is. Have you looked at the raw html it produces? Too many single quotes...
Code:
action="<?php echo base_url('users/mod_pers_data_act'); ?>"
#4

[eluser]InsiteFX[/eluser]
Maybe if you show your whole form we might be able to help.

This is why I love FireFox and FireBug lol.
#5

[eluser]Alhazred[/eluser]
Here is the form code, I've left only one field, it doesn't work anyway
Code:
<?php
$attributes = array('id' => 'moduserdata');
echo form_open(base_url('users/mod_pers_data_act'), $attributes);
?>
<input type='text' id='nome' name='nome' value="<?php echo $this->session->userdata('nome') ?>" />
<input type='submit' name='submit' value='<?php echo lang('crd_form_confirm_btn') ?>'/>
</form>
The controller's function is
Code:
public function mod_pers_data_act()
{
echo $_POST['nome']; //prints an error for missing index
echo $this->input->post('nome'); //prints nothing
echo "blabla"; //this is printed
}
#6

[eluser]CroNiX[/eluser]
It doesn't work because of all of your single quotes within single quotes, like I pointed out earlier.
You are also using form_open() improperly. It automatically inserts the base url, so you probably have that showing up twice. You just tell it the segments.
Code:
form_open('users/mod_pers_data_act');

Although, that won't help where you are (again) improperly using single quotes, such as your submit input.
#7

[eluser]Alhazred[/eluser]
Thanks it works now.




Theme © iAndrew 2016 - Forum software by © MyBB