Solid Posted December 17, 2012 Share Posted December 17, 2012 Hi all. Im trying go abit beyond the chapters of the yii-book, and im struggeling with the update of a database. I cant seem to figure out how i update an existing row. So im trying to build a e-mail verification, a user registers and gets an email with a link to myproject.com/verify?id=ID&verificationcode=VERIFICATIONCODE, and the verifypage picks it up and runs my actionVerify() method: public function actionVerify() { $model=User::model()->findByPk($_POST['id']); $model->attributes=$_POST['Verify']; if($model->validate()) { Yii::app()->user->setFlash('validated','<h2>Your E-mail is validated!</h2><p>You can now log in using the form below.</p>'); $model->save(); $this->redirect(Yii::app()->homeUrl/login); } } I've tried for a few hours now, starting of with using $model = new User, that ofcourse generates an error as you cant update an existing row with the creation of a new object. The code i have pasted over here generates the following error: Undefined index: id So im kinda stuck here, and im sure the solution is close to something i've tried. I have googled this alot, but the lack of well-explained articles kills me. I just dont have the understandment of yii/oop to use the manual or short articles just yet. Any help is appriciated, thanks in advance. Link to comment Share on other sites More sharing options...
Ziggi Posted December 17, 2012 Share Posted December 17, 2012 Hmm, As far as I can see you should rather try using GET method in your code rather than POST: $model=User::model()->findByPk($_GET['id']); etc. 1 Link to comment Share on other sites More sharing options...
Solid Posted December 17, 2012 Author Share Posted December 17, 2012 Nah, for now im just trying to post the data manually in a form in the validation-page. Its the update-code thats not working... I dident explain that well enough in the first post, my bad. Link to comment Share on other sites More sharing options...
Recommended Posts