thinkphp Automatic verification failure and its solution

Source: Internet
Author: User
Tags array manual php class require

 /*

 * Login  */Public Function login () {if ($_post[' submit ']) {$DB = D (' Login ');//Custom model processing    //if inside is th Automatic verification of the inkphp. if (! $DB->create ()) {$this->redirect (' Index/login ', ', ', 3, ' Error message: '. $DB->geterror (). ' <br/> system will return in 3 seconds after landing ... '); }else{$con [' LoginName '] = $_post[' username ']; $con [' loginpwd ']  = MD5 ($_post[' userpwd ']); $list = $DB->where ($ Con)->find (); if (count ($list) >0) {echo ' OK ';} else{$this->redirect (' Index/login ', ', ', 3, ' error message: User name or password error <br/> system will return in 3 seconds after landing ... ');} return; ///Here just encapsulates the address of the template file. A (' Public ')->showpage (' login ');  }   <?php class Loginmodel extends Model {//set datasheet protected $tableName = ' admin '; //automatic Validation settings protect ed $_validate = Array (' username ', ' require ', ' username must be! ', 1, Array (' userpwd ', ' require ', ' Password must be! ', 1),); /* Auto-fill if it is not automatically validated, uncomment this code to see. Protected $_auto = Array (' status ', ' 1 ', Self::model_insert), Array (' Create_time ', ' time ', Self::model_insert, ') function ');Manual: thinkphp manual type checking is only for database level validation, so the system also has built-in data object automatic validation to complete the business rule validation for the model, and in most cases the data object is created by the $_post data submitted by the form. Need to use the automatic verification function of the system, only need to define the $_validate attribute in the Model class * * * It says here, just need to define the $_validate attribute in the model class, but when using ThinkPHP2.1, it really does not pass the verification, $ Db->geterror () returns with no error reason and $db->geterror () returns "token form error"/}?> when refreshing.




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.