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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -