thinkphp analysis of the related solutions to the form token error _php instance

Source: Internet
Author: User
Tags php template smarty template

This paper analyzes the relevant solutions of thinkphp form token errors. Share to everyone for your reference, specific as follows:

Today in the use of thinkphp to do the program, used to create data, when the error prompted "form token error", and then a variety of Baidu all kinds of Google, the online solution given the following suggestions

1, Clear cache: Used, I put all the cache under the files are deleted, and will ~app.php and ~runtime.php two files at the same time deleted, but no effect.

2, set the token_on parameter to false: tried, but also not, although not prompt the form token error, but the data added to the database is empty.

3. Add {__notoken__} in the form of template file: added, but the result is also invalid!

Here I began to have no language, is not the thinkphp on my computer? I think it is not, I wrote another add function, the result is normal, this time I began to think, is not my last function write wrong? But after the inspection, yes! Later slowly a file began that view Ah, finally let me find the reason:

In the thinkphp automatically generated folders, there is a folder called "Data", there is a "_fields" folder, which is stored in the various models of the data table in the relevant information, but also as a mapping (my understanding), I carefully examined one, found that There are two files that have only "' _autoinc ' => true," and the others have a lot, similar to:

<?php return
Array (
 0 => ' id ',
 1 => ' title ',
 2 => ' content ',
 3 => ' Publishedtime ', C6/>4 => ' userid ',
 5 => ' params ',
 ' _autoinc ' => true,
 ' _pk ' => ' id ',
);
? >

By this time, you'll know why. is an operation of these data to delete a part, so that thinkphp in the form verification, the data can not be mapped, also led to the thinkphp error, will they in accordance with the order of the data table added, rerun, normal!

To this, the problem solved ~ ~ ~ ~

(The thinkphp environment in this article is an earlier version, the user can refer to the corresponding catalogue when using the new version)

PS: Here recommend a few of the site's format/landscaping/conversion tools to help you organize the messy code, I believe that we can use in future development:

PHP code online format Landscaping tools:
Http://tools.jb51.net/code/phpformat

JavaScript code Landscaping/compression/formatting/encryption Tools:
http://tools.jb51.net/code/jscompress

Online XML format/compression tools:
Http://tools.jb51.net/code/xmlformat

JSON Code Formatting Landscaping tool:
Http://tools.jb51.net/code/json

Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson

JSON code online Format/beautify/compress/edit/Convert tools:
Http://tools.jb51.net/code/jsoncodeformat

SQL code Online formatting Landscaping tools:
Http://tools.jb51.net/code/sqlcodeformat

More interested in thinkphp related content readers can view the site topics: "thinkphp Introductory Course", "thinkphp Common Methods Summary", "PHP Cookie Usage Summary", "Smarty Template Introductory Course" and "PHP template technology Summary."

I hope this article will help you with the PHP program design based on thinkphp framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.