php - get UserId when the button is clicked -
i want update find userid when button clicked.
as example suppose user name "dell" have "userid" "111", when button clicked in should select user , further action.
that's why use "$_post", when user clicks button return "userid".
this how trying the "userid".
$usrinfo = $this->getdoctrine() ->getrepository('mybundle:userstats') ->findbyuserid($_post);
but think doing wrong, cause not working when user clicks button.
and based on userid, update information like---
$usrst = new userstats();
$providerstats->seton(false); $em = $this->getdoctrine()->getmanager(); $em->persist($usrinfo); $em->flush();
so again main purpose find userid when button clicked. knows knows how solve problem. in advanced.
you can try (i assume you're using form component, better if post form):
... public function someaction(request $request) { .... $form = $this->createform(type, null_or_data, options); $form->handlerequest($request); if ($form->isvalid()) { $username = $form->get('username_field')->getdata(); $user = (someservice_or_repository)->getuserbyusername($username); // here user // flush changes .... } .... }
Comments
Post a Comment