Index.html
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
UserModel.class.php
<?php
class Usermodel extends model{
//Parameters:
//1. Validation fields (names in the form or auxiliary fields such as Authenticode)
//2. Validation rules (used with additional rules)
//3. Error reminder
//4. Validation conditions (0:1:2:) It is best to select constants in the manual to fill
//5. Additional rules; authentication method: Regex;function name; callback;confirm (verify two fields are the same Equal;in;unique
// common rules: require: must exist; email mailbox; url;currency currency; number;
//6. Verification time
// Refers to the database when the database operation of the verification time (add data, edit, all clear under Validation)
// Model::model_insert
// model::model_update
/ / Model::model_both//
automatic verification start
protected $_validate=array (
' username ', ' require ', ' username required ') , 0,0,1),
Array (' username ', ' checklen ', ' username length not valid ', 0, ' callback ', 3),
Array (' Password ', ' require ', ' username required ', 0,0,1),
array (' Repassword ', ' require ', ' username required ', 0,0,1),
Array (' Password ', ' Repassword ', ' inconsistent password ', 0, ' Confirm ', 1),
// Array (' Createip ', ' email ', ' mailbox format not correct ', 0, ' regex ', 1)
;
Public Function Checklen ($data) {
if (strlen ($data) >15| | Strlen ($data) <5) return
FALSE;
return true;
}
function Modeltest () {
echo ' test cross model operation, calling method ';} ' in the
model
? >
AutoAction.class.php
* Automatic validation in <?php/** * thinkphp
(takes effect when create method in action)
* mainly written in custom model, validate the form or field in the database when you finish entering information
* Auto-complete
* The field that the user entered is not the user's manual input *
field mapping
* Prevents the user from seeing the field name from the foreground and guessing the name of the field in the database table
*
* */ Class Autoaction extends action{public
function Index () {
$this->display ();
}
function Add () {
//Custom model
$user =d (' user ');
if ($user->create ()) {
if ($user->add ()) {
$this->success ("registered successfully");
} else{
$this->error ($user->geterror ());
}
else{
$this->error ($user->geterror ());}}
? >