public function actionUserinfoUpdate($id = 0) { if (!($resutl = $this->_validUserRequest($id))) { $this->redirect(array('user/view', 'id' => $id)); } $model = new Userinfo(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='userinfo-UserinfoUpdate-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ if (isset($_POST['Userinfo'])) { try { $model = Userinfo::model()->with('userRel')->findByPk(Yii::app()->getId()); if ($model == NULL) { $model = new Userinfo(); $model->attributes = $_POST['Userinfo']; } else { $model->attributes = $_POST['Userinfo']; } if ($model->save()) { $this->render('view', array('model' => $model)); } else { $this->render('UserinfoUpdate', array('model' => $model)); } //echo '<pre>'; var_dump($model); echo '</pre>'; die(); } catch (Exception $e) { throw new CHttpException(404, 'The requested page does not exist.'); } } $this->render('UserinfoUpdate', array('model' => $model)); }
public function saveInfo($id) { echo "<pre>"; print_r($_POST); die; if (isset($_POST['Userinfo']) && !empty($_POST['Userinfo'])) { if ($_POST['Userinfo']['form_type'] == "profession") { $post = new Userinfo(); $post->category_id = $_POST['Userinfo']['category_id']; $post->skill_levell = $_POST['Userinfo']['skill_levell']; $post->skill_id = $_POST['Userinfo']['skill_id']; $post->secondary_talent = $_POST['Userinfo']['secondary_talent']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "basic") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); //$post->name=$_POST['Userinfo']['name']; //$post->email=$_POST['Userinfo']['email']; $post->dob = $_POST['Userinfo']['phone']; $post->gender = $_POST['Userinfo']['gender']; $post->nationality = $_POST['Userinfo']['nationality']; $post->education = $_POST['Userinfo']['education']; $post->school_name = $_POST['Userinfo']['school_name']; $post->date = $_POST['Userinfo']['date']; $post->field_of_study = $_POST['Userinfo']['field_of_study']; $post->description = $_POST['Userinfo']['description']; $post->save(); //$userPost= new User(); $userPost = User::model()->findByPk(50); if (!empty($_POST['Userinfo']['name'])) { $userPost->first_name = $_POST['Userinfo']['name']; } if (!empty($_POST['Userinfo']['email'])) { $userPost->first_name = $_POST['Userinfo']['email']; } $userPost->save(); } elseif ($_POST['Userinfo']['form_type'] == "experience") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); //$post->name=$_POST['Userinfo']['name']; //$post->email=$_POST['Userinfo']['email']; $post->company_name = $_POST['Userinfo']['company_name']; $post->position = $_POST['Userinfo']['position']; $post->experience = $_POST['Userinfo']['experience']; $post->exp_description = $_POST['Userinfo']['exp_description']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "awards") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); //$post->name=$_POST['Userinfo']['name']; //$post->email=$_POST['Userinfo']['email']; $post->award_title = $_POST['Userinfo']['award_title']; $post->award = $_POST['Userinfo']['award']; $post->year = $_POST['Userinfo']['year']; $post->award_description = $_POST['Userinfo']['award_description']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "interests") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); $post->interests = $_POST['Userinfo']['interests']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "privacy") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); $post->message = $_POST['Userinfo']['message']; $post->connect = $_POST['Userinfo']['connect']; $post->see_phone = $_POST['Userinfo']['see_phone']; $post->see_dob = $_POST['Userinfo']['see_dob']; $post->save(); } return true; } }
/** * 添加 User 后台用户 */ public function actionAdduser() { $UserModel = new Account(); $SQL = array('select' => 'name,id'); $DownList = Role::model()->findAll($SQL); $List = array(); foreach ($DownList as $key => $value) { $List[$value->id] = $value->name; } if ($_POST) { $Post = $_POST['Account']; $UserModel->roleId = $Post['roleId']; $UserModel->account = $Post['account']; $UserModel->password = $Post['password']; $UserModel->time = date('Y-m-d H:i:s', time()); $UserModel->type = 0; if ($UserModel->save(false)) { $UID = $UserModel->attributes['id']; $User = new Userinfo(); $User->accountId = $UID; $User->niekname = $Post['niekname']; $User->website = $Post['website']; $User->describe = $Post['describe']; $User->time = date('Y-m-d H:i:s', time()); $User->QQ = $Post['QQ']; if ($User->save(false)) { Yii::app()->user->setFlash('modify', '用户新增成功!'); } } } $this->render('add_user', array('Model' => $UserModel, 'List' => $List)); }