Class Usermodel extends model{
Protected $_validate=array (
You will also need to write an array below. An array is a validation rule
Array (' Validation field ', ' Validation rule ', ' ERROR hint ', ' validation condition ', ' additional rule ', ' verification time '),
Validation fields: The name of a form field that needs to be validated, or some auxiliary fields in a form, such as a CAPTCHA, an encryption, a duplicate password, etc.
Validation rules, validation rules must be used in conjunction with additional rules
Error TIP: If there is an error, throw a message that tells the user
Verification Condition: 0,1,2 ()
Additional rules:
Regex enables 肜 to verify that you can write a regular expression in the validation rule (the first brother-even forum downloads the regular video of the high teacher,
Second, the thinkphp function is strong he closed some regular for us, third, the Internet has to prepare some common regular
function is validated using functions, the previous validation rule this place must write function name time
Callback is a callback he's going to find a member of the current Usermodel method
Confirm Verify that two fields in the form are equal.
Equal is equal to a value under the main test
In whether in a range of validation rules need to write an array
Unique validation is unique, the system will be based on the current value of the field query the database to determine whether there is the same value
//
If you use some of the usual regular systems built into your system, just write to the error prompts,
Require field must verify email authentication mailbox URL is currency currency number that validates the URL address
Verification time: Refers to the timing of the verification of database operation time
1 validation Model::model_insert When new data is added
2 when editing to verify Model::model_update
3 Verify Model::model_both in all cases
//
Array ("user_name", "Require", "User name must be filled in!"),
Array ("user_name", "6,12", "username must be between 6 and 12 digits", 0, "Length"),
Array ("Real_name", "require", "need to fill in the real name!") "),
Array ("Password", "Require", "password must be filled in!") "),
Array ("Password", "8,12", "Password must be between 8 and 12 digits", 0, "Length"),
Array ("Repassword", "Require", "duplicate password must be filled out!") "),
Array ("Password", "Repassword", "Two input passwords inconsistent", 0, "confirm"),
Array ("email", "Require", "mailbox must be filled in"),
Array ("email", "email", "Mailbox format is wrong!") ", 1),
Array ("Verify", "Require", "verification code must be filled in"),
Array ("Code", "Checkcode", "Validation code input Error", 0, "callback"),
);
Protected $_auto=array (
Array (' Fill field ', ' Fill content ', ' Fill condition ', ' additional rule ');
Fill field: This field can be a field in a form or a field in a database. can also be some secondary fields
Fill in the content and use it together with additional rules
padding conditions, 1,2,3 respectively for new, edited, and all cases Model::model_insert (the default parameter is filled when new)
Additional rules, function callback, field (populated with other fields), which means you can get a value for another field here
String, which is populated by strings. This is the default option that the thinkphp automatically completes inside
Array ("Password", "MD5", 3, "function"),
Array ("Age", "Deal_int", 3, "callback"),
);
Protected $_map=array (
"username" => "user_name",//different thinkphp versions may vary, note that the fields in the $_validate correspond
"Realname" => "real_name",//"is to be written in the fields in the front ' => ' is written to the back, the real field in the datasheet is written to the back ',
);
protected function Deal_int ($data) {
return (int) $data;
}
protected function Checkcode ($data) {
if (MD5 ($_post[' code '))!=$_session[' verify '] {
return false;
}
return true;
}
}