當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTimeHelper::convertToDTStringFromPOSTForFieldName方法代碼示例

本文整理匯總了PHP中DateTimeHelper::convertToDTStringFromPOSTForFieldName方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTimeHelper::convertToDTStringFromPOSTForFieldName方法的具體用法?PHP DateTimeHelper::convertToDTStringFromPOSTForFieldName怎麽用?PHP DateTimeHelper::convertToDTStringFromPOSTForFieldName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateTimeHelper的用法示例。


在下文中一共展示了DateTimeHelper::convertToDTStringFromPOSTForFieldName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionRegister

 public function actionRegister()
 {
     $model = new User('register');
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->setAttributes($_POST['User']);
         $model->birthday = DateTimeHelper::convertToDTStringFromPOSTForFieldName('birthday', $_POST);
         //captcha validating
         require_once Yii::app()->basePath . '/vendor/recaptchalib.php';
         $privatekey = "6LfXBe8SAAAAAA7fOOWIfyfmvWbIjk-s15UFfGec";
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$resp->is_valid) {
             $error = $resp->error;
             if ($resp->error == 'incorrect-captcha-sol') {
                 $error = '確認碼不正確';
             }
             $this->render('register', array('model' => $model, 'captchaError' => $error));
             return;
         } else {
             // Your code here to handle a successful verification
             /** store the password for the athentication user
              *  Since the password will be hashed once it is saved
              */
             $rawPassword = $model->password;
             if ($model->validate()) {
                 if ($model->save()) {
                     $identity = new UserIdentity($model->user_name, $rawPassword);
                     $duration = 3600 * 24 * 30;
                     // 30 days
                     $identity->authenticate();
                     if (Yii::app()->user->login($identity, $duration)) {
                         Yii::app()->user->setFlash(FlashMsg::SUCCESS, "歡迎加入!");
                     } else {
                         Yii::app()->user->setFlash(FlashMsg::WARNING, "歡迎加入! 請在登入頁麵登入");
                     }
                     $this->redirect(array('index'));
                 } else {
                     Yii::app()->user->setFlash(FlashMsg::ERROR, "創建使用者失敗");
                 }
             } else {
                 $model->purgePassword();
             }
         }
     }
     $this->render('register', array('model' => $model, 'captchaError' => ''));
 }
開發者ID:kittolau,項目名稱:gcm,代碼行數:47,代碼來源:SiteController.php

示例2: actionUpdateUser

 public function actionUpdateUser()
 {
     $model = User::model()->findByPk(Yii::app()->user->id);
     $fileModel = new FileUploadFormModel();
     $fileModel->setScenario(FileUploadFormModel::FILE_UPLOAD_MODE_SINGLE);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->setScenario('update');
         $model->setAttributes($_POST['User']);
         $model->birthday = DateTimeHelper::convertToDTStringFromPOSTForFieldName('birthday', $_POST);
         $test = $model->summary;
         if ($model->validate()) {
             $fileModel->LoadUploadedeImage();
             if ($fileModel->isUploadedFile()) {
                 if ($fileModel->validate()) {
                     $SavedFileRelativePaths = $fileModel->processImage(get_class($model), $model->user_name, md5(DateTimeHelper::now()));
                     $model->icon_src = ArrayHelper::array2string($SavedFileRelativePaths);
                     if ($model->save()) {
                         Yii::app()->user->setFlash(FlashMsg::SUCCESS, "個人資料已更新");
                         $this->redirect(array('index'));
                     } else {
                         Yii::app()->user->setFlash(FlashMsg::ERROR, "更新個人資料失敗");
                     }
                 } else {
                     $this->render('updateUser', array('model' => $model, 'fileModel' => $fileModel));
                 }
             }
             if ($model->save()) {
                 Yii::app()->user->setFlash(FlashMsg::SUCCESS, "個人資料已更新");
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('updateUser', array('model' => $model, 'fileModel' => $fileModel));
 }
開發者ID:kittolau,項目名稱:gcm,代碼行數:36,代碼來源:MemberCenterController.php


注:本文中的DateTimeHelper::convertToDTStringFromPOSTForFieldName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。