Copy CodeThe code is 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 CodeThe code is as follows:
<?php
Class Loginmodel extends Model {
Setting up a data table
Protected $tableName = ' admin ';
Automatic Validation settings
Protected $_validate = Array (
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 (
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, 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 property in the Model class
*/
/* It says here, just want to define the $_validate attribute in the model class, but in the use of ThinkPHP2.1, it does not pass the validation, $DB->geterror () No error reason to return, and refresh the time $db-> GetError () returns a "token form error"
*/
}
?>
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.