Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6345179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:46:19+00:00 2026-05-24T20:46:19+00:00

Here is my form: <form novalidate action=<?php echo url_for(‘article/submit’) ?> method=POST> <?php echo $form[‘title’]->renderRow()

  • 0

Here is my form:

<form novalidate action="<?php echo url_for('article/submit') ?>" method="POST">
  <?php echo $form['title']->renderRow() ?>
  <?php echo $form['content']->renderRow() ?>
  <?php echo $form->renderHiddenFields() ?>
  <input type="submit" value="Save"/>
</form>

And looking at the generated HTML source, the _csrf_token IS in fact being rendered. Here is my action:

public function executeSubmit(sfWebRequest $request)
{
  $this->forward404Unless($request->isMethod('post'));
  $request->checkCSRFProtection();

  die('submitting post...');
}

The error:

_csrf_token [CSRF attack detected.]

Even in my action if I do a var_dump($_POST); die; I get:

Array
(
  [title] => string(8) "My title"
  [content] => string(10) "My Content"
  [_csrf_token] => string(32) "<my token here>"
)

So the csrf token is definitely being rendered and passed correctly. What am I doing wrong?

Also, is there any documentation for checkCSRFProtection() anywhere? The API doc’s dont’ say anything about it besides acknowledging it’s existence.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:46:20+00:00Added an answer on May 24, 2026 at 8:46 pm

    A few things to check:

    (Source: From http://oldforum.symfony-project.org/index.php/t/17867/)

    Be sure you have defined your “secret” in your settings:

    csrf_secret: ThisIsMySecret  # Unique secret to enable CSRF protection or false to disable`
    

    Also, based on what I’ve gathered from that form post, CSRF protection checking is done automatically in $this->form->isValid(), so your call to $request->checkCSRFProtection() is unnecessary if you are already checking if the form is valid. If not, add $this->form->isValid().

    It would also seem that $request->checkCSRFProtection() doesn’t work with forms; it’s purpose (if I’m correct) is to validate requests served when a user clicks a link. When CSRF protection is enabled, link_to() automatically adds CSRF protection to the links it generates. So, basically, the CSRF protection for a form is different for that of a request that didn’t originate from a form.

    See this ticket for more details: http://trac.symfony-project.org/ticket/7315

    Another ticket that may be of interest: http://trac.symfony-project.org/ticket/5698

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the form submission part var form=document.forms[mainForm]; form.setAttribute(action,url_action); form.setAttribute(method,post); form.setAttribute(enctype,multipart/form-data); form.setAttribute(encoding,multipart/form-data); form.submit(); Now
I have created a hidden form element <form name=UploadImage enctype=multipart/form-data method=post action=UploadImage> <label> </label>
Here is a simple form I am using to send XML data in admin_xml.php
Here is a code form a PHP+MySQL book I am reading and I am
so here's the problem I have one form, it outputs search results after submit,
I have a form here when you press Click To Test Signup : http://www.problemio.com/test.php
Am Newbie here.Am Beginner in php.I Create a sample Reg form.Here i want to
So I have this form here: http://www.piataterenuri.info/register.php The problem is that Firefox caches the
I have the same problem as here Form Post with Facebook C# SDK when
I have a basic PHP form here that sends an email when submitted: <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.