奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

php語言

PHP中Yii框架之表單驗證規則

時間:2025-04-02 07:08:37 php語言 我要投稿
  • 相關推薦

PHP中Yii框架之表單驗證規則

  Yii是一個基于組件的高性能PHP框架,用于開發大型Web應用。Yii采用嚴格的OOP編寫,并有著完善的庫引用以及全面的教程,本文給大家介紹php yii框架之表單驗證規則大全,感興趣的朋友一起學習吧.

  Yii是一個基于組件的高性能PHP框架,用于開發大型Web應用。Yii采用嚴格的OOP編寫,并有著完善的庫引用以及全面的教程。

  <?php

  class ContactForm extends CFormModel

  {

  public $_id;

  public $contact;//聯系人

  public $tel;//電話

  public $fax;//傳真

  public $zipcode;//郵編

  public $addr;//地址

  public $mobile;//手機

  public $email;//郵箱

  public $website;//網址

  public $qq;//QQ

  public $msn;//MSN

  public function rules()

  {

  return array(

  array('contact','required','on'=>'edit','message'=>'聯系人必須填寫.'),

  array('contact','length','on'=>'edit','min'=>2,'max'=>10,'tooShort'=>'聯系人長度請控制在2-10個字符.','tooLong'=>'聯系人長度請控制在2-10個字符.'),

  array('tel', 'match','pattern' => '/^(\d{3}-|\d{4}-)(\d{8}|\d{7})?$/','message' => '請輸入正確的電話號碼.'),

  array('fax', 'match','pattern' => '/^(\d{3}-|\d{4}-)(\d{8}|\d{7})?$/','message' => '請輸入正確的傳真號碼.'),

  array('mobile', 'match','pattern' => '/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/','message' => '請輸入正確的手機號碼.'),

  array('email','email','on'=>'edit','message'=>'郵箱輸入有誤.'),

  array('zipcode','required','on'=>'edit','message'=>'郵編必須填寫.'),

  array('zipcode','numerical','on'=>'edit','message'=>'郵編是6位數字.'),

  array('zipcode','length','on'=>'edit','min'=>6,'max'=>6,'tooShort'=>'郵編長度為6位數.','tooLong'=>'郵編長度為6位數.'),

  array('website','url','on'=>'edit','message'=>'網址輸入有誤.'),

  array('qq', 'match','pattern' => '/^[1-9]{1}[0-9]{4,11}$/','message' => '請輸入正確的QQ號碼.'),

  array('msn','email','on'=>'edit','message'=>'MSN輸入有誤.'),

  );

  }

  }

  完整示例:

  ?

  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  13

  14

  15

  16

  17

  18

  19

  20

  21

  22

  23

  24

  25

  26

  27

  28

  29

  30

  31

  32

  33

  34

  35

  36

  37

  38

  39

  40

  41

  42

  43

  44

  45

  46

  47

  48

  49

  50

  51

  52

  53

  54

  55

  56

  57

  58

  59

  60

  61

  62

  63

  64

  65

  66

  67

  68

  69

  70

  71

  72

  73

  74

  75

  76

  77

  public $password2;//非數據庫的字段,但是在view中需要用到

  public $verify; //手機驗證碼

  public $fjg; //忘記號碼

  /**

  * 映射數據庫表名

  * @return string the associated database table name<br><br>     * www.shouce.ren

  */

  public function tableName()

  {

  return 'adm_user';

  }

  /**

  * 驗證規則

  * @return array validation rules for model attributes.

  */

  public function rules()

  {

  // NOTE: you should only define rules for those attributes that

  // will receive user inputs.

  return array(

  //array('mobile_phone,name,status', 'required'),

  array('mobile_phone', 'unique'),//'message' => '該手機號已經存在!'

  array('mobile_phone', 'match','pattern' => '/^(13|15|18)[0-9]{9}$/','message' => '請輸入正確的經辦人手機號碼.'),

  //array('certificate_id', 'match','pattern' => '/(.jpg|.gif|.png|\d)$/','message' => '請重新選擇證書圖像并且后綴只能是jpg、gif、png格式.'),

  array('phone', 'match','pattern' => '/^(\d{3}-|\d{4}-)?(\d{8}|\d{7})?$/','message' => '請輸入正確的座機號碼.'),

  array('fax', 'match','pattern' => '/^(\d{3}-|\d{4}-)(\d{8}|\d{7})?$/','message' => '請輸入正確的傳真號碼.'),

  //array('email_address', 'match','pattern' => '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/','message' => '請輸入正確的郵箱.'),

  array('email_address','email','message'=>'請輸入正確的郵箱.'),

  //驗證密碼和確認密碼

  array("password2","compare","compareAttribute"=>"password","message"=>"兩次密碼不一致",'on'=>'register'),

  array("password2","compare","compareAttribute"=>"password","message"=>"兩次密碼不一致",'on'=>'regonter'),

  array('qq', 'match','pattern' => '/^[1-9]{1}[0-9]{4,11}$/','message' => '請輸入正確的QQ號碼.'),

  array('type,certificate_id,company_type, nationality,yyzz_id, status,level,create_by_id, create_time,update_time', 'numerical', 'integerOnly'=>true),

  array('verify', 'numerical', 'message' => '驗證碼不正確','integerOnly'=>true),

  array('name,user_type,tuijianren', 'length', 'max'=>20),

  array('password', 'length', 'max'=>100),

  array('email_address,business', 'length', 'max'=>50),

  array('communication_address,money, yhzh,yhmc,industry, company, register_address,yhdh,shangbiao,zhuanli,gongshang', 'length', 'max'=>255),

  array('role_id','default', 'setOnEmpty'=>true, 'value'=>10),

  array('shangbiao','default', 'setOnEmpty'=>true, 'value'=>'0,0'),

  array('zhuanli','default', 'setOnEmpty'=>true, 'value'=>'0,0'),

  array('gongshang','default', 'setOnEmpty'=>true, 'value'=>'0,0'),

  array('password','default', 'setOnEmpty'=>true, 'value'=>'123456'),

  /*驗證碼*/

  array('verify','checkVerify', 'on'=>'register'),

  array('email_address','checkemail', 'on'=>'regonter'),

  //     array('certificate_id', 'file','allowEmpty'=>true,

  //         'types'=>'jpg, gif, png, doc, txt',

  //         'maxSize'=>1024 * 1024 * 10, // 10MB

  //         'tooLarge'=>'文件大小不能超過10M!',

  //         'message'=>'請先上傳證書圖像.'

  //     ),

  // The following rule is used by search().

  // @todo Please remove those attributes that should not be searched.

  array('id,role_id,name, password,user_type, email_address,tuijianren,shangbiao,company_type,zhuanli,gongshang,money,yhzh,yhmc,yyzz_id,yhdh,type,level, phone, qq, mobile_phone, fax, communication_address, nationality, industry, company, business, register_address, certificate, status, create_by_id, create_time, update_time', 'safe', 'on'=>'search'),

  );

  }

  /*

  * 手機驗證碼校驗

  */

  public function checkVerify($attribute,$params)

  {

  $model=new Mess();

  $d_title = $model->find(array('condition'=>'suij=:suij and tel=:tel and type>:type and time>:time','params'=>array(':suij'=>$this->verify,':tel'=>$this->mobile_phone,':type'=>0,':time'=>(time()-3600)),'select'=>array('id')));

  //$d_title = $model->findByAttributes(array('suij'=>$this->verify,'tel'=>$this->mobile_phone),array('select'=>array('id')));

  if($d_title['id']<1)

  {

  $this->addError('verify', "驗證碼不正確。");

  }

  else

  {

  if($this->password == $this->password2)

  {

  $model->updateAll(array('type'=>0),array('condition'=>'suij=:sj','params'=>array(':sj'=>$this->verify)));

  }

  }

  }

【PHP中Yii框架之表單驗證規則】相關文章:

php編程必學之表單驗證12-11

PHP 表單驗證方法05-07

Yii框架form表單用法實例02-06

php中tp驗證表單與自動填充函數代碼07-16

PHP中的表單處理05-24

基于PHP+Ajax實現表單驗證的詳解05-19

PHP 表單驗證 E-mail 和 URL04-09

用php常用表單驗證的正則表達式02-27

ThinkPHP中create()方法自動驗證表單信息01-26

主站蜘蛛池模板: 灯塔市| 杭锦后旗| 敦化市| 邹城市| 长顺县| 绥宁县| 顺平县| 南京市| 常德市| 西青区| 平舆县| 康定县| 依兰县| 尉氏县| 景宁| 蛟河市| 荣成市| 沅陵县| 全州县| 万年县| 辰溪县| 上犹县| 界首市| 乌海市| 阳城县| 紫阳县| 海盐县| 庄河市| 石林| 昌乐县| 成安县| 隆子县| 常德市| 洪洞县| 那坡县| 嵊州市| 波密县| 新民市| 神农架林区| 涟源市| 新源县|