2

i have a problem with passing POST data. when i check the post data with firebug the data is there. but when i check it in my controller there is nothing.

this is my form:

<form action="<?php echo base_url(); ?>cms/activiteit/saveAct" method="post">
 <div class="row">
 <div class="col-md-3">Titel:</div>
 <input class="col-md-9" type="text" name="title" id="title"/>
 </div>
 <div class="row">
 <div class="col-md-3">Datum:</div>
 <input class="col-md-9" type="date" name="date" id="date"/>
 </div>
 <div class="row">
 <div class="col-md-3">Korte beschrijving:</div>
 <input class="col-md-9" type="text" name="short" id="short"/>
 </div>
 <div class="row">
 <div class="col-md-3">Lange beschrijving:</div>
 <textarea class="col-md-9" name="long" id="long"></textarea>
 </div>
 <div class="row">
 <div class="col-md-12 spatie"></div>
 </div>
 <div class="row">
 <input type="submit" class="col-md-9 col-md-offset-3 btn btn-info" value="Opslaan"/>
 </div>
</form>

in my controller i have this:

public function saveAct()
{
 $this->output->enable_profiler();
 echo 'title: ' . $this->input->post('title');
}

in this picture is the output of the saveAct controller part i read somewhere that this could be my htacces file.

RewriteEngine on
RewriteRule ^(application) - [F,L]
RewriteCond 1ドル !^(index\.php|assets/|assets/bootstrap/|assets/CSS/|assets/font/|assets/font-awesome/|assets/img/|assets/javascript/|assets/JQuery/|cms/|cms/bootstrap/|cms/CSS/|cms/font-awesome/|cms/img/|cms/javascript/|cms/JQuery/|public/)
RewriteRule ^(.*)$ index.php?/1ドル [L]

thanks for the help.

asked Nov 11, 2014 at 12:40
8
  • 1
    can you display the result of var_dump($_POST); ? Commented Nov 11, 2014 at 12:42
  • what is controller name post your base url also Commented Nov 11, 2014 at 12:47
  • is it ajax request or non ajax? if ajax, show the js code also. Commented Nov 11, 2014 at 12:48
  • have u load html,url and form helper? Commented Nov 11, 2014 at 12:53
  • -DARK_DUCK: --> array(0) { } Commented Nov 11, 2014 at 13:25

1 Answer 1

1

looks like incorrect form action

Try to change :-

<form action="<?php echo base_url(); ?>cms/activiteit/saveAct" method="post">

to

<?php echo form_open('activiteit/saveAct');?>

will auto get your site base url and post to controller(activiteit) method(saveAct)

For more :- https://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

leave empty Base url in config or set it to your CI directory http://localhost/yourdir/

answered Nov 11, 2014 at 12:54
Sign up to request clarification or add additional context in comments.

5 Comments

as controller name AND installation directory is not provided this answer assumes that cms is the installation directory, activiteit - controller AND saveAct - method which CAN be the case . BUT i can see title: echod in the OP pic, any explanation about that ?
@karan i am also assuming base url included dir?
cms is a dir into controllers
@rakesh sharma: is i use the <?php echo form_open('cms/activiteit/saveAct');?> it works can you tell me why? it gives this as result: <form action="perdje.be/index.php/cms/activiteit/saveAct" method="post" accept-charset="utf-8">
may be missing in action url try to check what you give or echo your full action url. better if you use CI standard. also you can accept helpful answer :)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.