Copy Code code as follows:
/*
* Landing
*/
Public Function Login () {
if ($_post[' submit ']) {
$DB = D (' Login ');//Custom model processing
If inside is the automatic verification of the thinkphp.
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: Username or password error <br/> system will return in 3 seconds after landing ... ');
}
}
return;
}
This just encapsulates the address of the template file.
A (' Public ')->showpage (' login ');
}
Copy Code code as follows:
<?php
Class Loginmodel extends Model {
//Set datasheet
Protected $tableName = ' admin ';
//Auto-Verify settings
Protected $_validate = Array (
Array (' username ', ' require ', ' username must be!) ', 1,
Array (' userpwd ', ' require ', ' password must! ', 1),
);
/* AutoFill If it is not automatically validated, uncomment this code to see.
Protected $_auto = Array (
Array (' status ', ' 1 ', self::model_insert),
Array (' Create_time ', ' time ', Self:: Model_insert, ' function '),
);/
/* Reference ThinkPHP2.0 Development Manual: thinkphp manual type checking is only for database-level validation, Therefore, the system also has built-in data object's automatic verification function to complete the model's business rule verification, and in most cases, the data object is created by the $_post data submitted by the form. You need to use the automatic verification function of the system, just define the $_validate property in the Model class
/
/* It says here, just define the $_validate attribute in the model class, but when using ThinkPHP2.1, Does not pass validation, $DB->geterror () returned without error, and $db->geterror () returns "token form error"
/
}
?>
when refreshed