Yii Framework Forum: My update function of controller is not working. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

My update function of controller is not working. My update function of controller is not working please help me. Rate Topic: -----

#1 User is offline   Alokkr 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 03-November 16

Posted 03 November 2016 - 02:02 AM

public function actionEditprofile()
{
if(isset($_POST['editform']))
{
$user = $_POST['user'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$editprofile = Login::model()->updateAll(array("condition" =>
"user = '$user'
firstname = '$firstname'
lastname = '$lastname' AND
email = '$email'"));
if($editprofile == null)
{
$editprofile = new Login;
$editprofile->user = $user;
$editprofile->firstname = $firstname;
$editprofile->lastname = $lastname;
$editprofile->email = $email;
if($editprofile->save())
{
$this->render("editprofile",array("msg"=>"Profile Update"));
}else
{
$this->render("editprofile",array("msg"=>"Profile Not Update"));
}
}else
{
$this->render("editprofile",array("msg"=>"Profile Not Update"));

}
}elseif(isset($_POST['addform']))
{
$user = $_POST['user'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];

$editprofile = Login::model()->updateAll(array("condition"=>"user = '$user'
firstname = '$firstname'
lastname = '$lastname' AND
email = '$email'"));
if($editprofile == null)
{
$editprofile = new Login;
$editprofile->user = $user;
$editprofile->firstname = $firstname;
$editprofile->lastname = $lastname;
$editprofile->email = $email;
if($editprofile->save())
{
$this->render("editprofile",array("msg"=>"Profile Update"));
}else
{
$this->render("editprofile",array("msg"=>"Profile Not Update"));
}
}else
{
$this->render("editprofile",array("msg"=>"Profile Not Update"));
}
}else
{
$this->render('editprofile');
}
}
0

#2 User is offline   weluse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 22-August 16

Posted 03 November 2016 - 05:05 AM

HI Alokkr,

can you please use the "Insert Code Snippet"?

And it is Yii2 ?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users