/*
* 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.