Welcome Guest, Not a member yet? Register   Sign In
Invalid CSRF token when submitting a form
#1

Hey guys,

I am really hoping you can help me get to the bottom of this, I have messed around with CI before but this is the first time I am actually trying to build a site with it. I have had some teething issues but have been able to find solutions to them but this one really has me stumped.

I am trying to add a form to a page (search bar) and have been getting various errors, the latest one is:
Quote:Invalid CSRF token.

this occurs when you try and submit the form, i have tried multiple 'fixes' via googling but nothing seems to do the trick my latest code is:

head.php - header of the site loading the search bar into the top of each page

Code:
   <!-- Start Searchbox -->
   <form class="searchform" method="POST" action="<?php echo site_url('stock/search');?>">
     <input type="text" class="searchbox" id="searchbox" name="searchTerm" placeholder="Search">
     <span class="searchbutton"><i class="fa fa-search"></i></span>
     <input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">

   </form>





   <!-- End Searchbox -->


config.php
Code:
*/
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'MLLTokenName';
$config['csrf_cookie_name'] = 'MLLCookieName';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = FALSE;
$config['csrf_exclude_uris'] = array();

/*


I am really hoping I have done something simple & obviously wrong because it can't be this hard to insert a simple form into a CI page & i am just starting to get to grips with CI so its frustrating to be stuck on something like this. 


Thank you for any help with this

all the best

Alex3410
Reply


Messages In This Thread
Invalid CSRF token when submitting a form - by alex3410 - 01-24-2018, 04:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB