Jump to content

Unable to fire create_post() from my MVC setup.


surreal5335

Recommended Posts

I have a comment board that is nearly completed although right now when you submit a new comment, the form action is done right but stays on the new page without calling the create_post() I created. The function does work, I have seen it work recently but while trying to get a page redirect from the called page back to the main page with all posts I was not able to get create_post() working again (I have not made any changes to create_post() ).

 

Here is the code for the form and where the action takes you to:

 

<form action = "<?php echo DS.APP_ROOT.DS;?>views/posts/create.php" method="post">
  <?php include('_form.php'); ?>
</form>

 

Here is the code for the page the form takes the user to (I expect this not to do anything valuable):

 

<?php print_r($params); ?>

 

This is the controller end that is suppose to call create_post() and hopefully execute the redirect back to the main page (this is my problem child):

 

switch($route['view']) {
case "create":
      if(create_post($params['post']))
      {
        flash_notice('Successfully created post!');
	redirect_to('posts');
      } 
  header( 'Location: http://www.royalvillicus.com/comment_board/' ) ;
    break;
}

 

This all worked at one point w/out the redirect. While trying to get the redirect to work, this stopped getting called. I did put an HTML redirect into my create.php file (the one with the print_r() ), the redirect worked but nothing got submitted to the database.

 

I am an array for the url routes in my config file. The one that helps determine which case: to execute in my controller. Here is the code for my 'create' url route.

 

'url' => '/^posts\/create$/', 'controller' => 'posts', 'view' => 'create'),

 

To see what I am talking about, here is my site url:

 

http://royalvillicus.com/comment_board/

 

Thanks a lot for the help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.