title: how to check if value of radio button is changed in PHP Codeiginter?
body: <p>Hello i want to deduct balance of Resellers. Each reseller has its own users so he can edit his users. now if reseller sets balance of user = yes then i want to deduct 5 euros from his account. So how do i know if the radio button value if changed from No to yes?</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;Balance&lt;/td&gt;
  &lt;td&gt;Yes&lt;?php echo form_radio('balance','Yes', $this-&gt;input-&gt;post('balance') ? $this-&gt;input-&gt;post('balance') : $user-&gt;balance);  ?&gt; No &lt;?php echo form_radio('balance','No', $this-&gt;input-&gt;post('balance') ? $this-&gt;input-&gt;post('balance') : $user-&gt;balance);  ?&gt;&lt;/td&gt;   
  &lt;/tr&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hvTLd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hvTLd.png" alt="Output"></a></p>
  
  <p>So now  after login if a reseller sets the balance of user to yes then 5 euros should be deducted! Please help me with this:</p>
  
  <p>The User Controller :</p>
  
  <pre><code>public function edit ($id = NULL)
  {
  
       $usertype=$this-&gt;session-&gt;userdata('usertype');
      if($usertype ==="reseller")
      {
  
      // Fetch a user or set a new one
      if ($id) {
          $this-&gt;data['user'] = $this-&gt;user_m-&gt;get($id);
          count($this-&gt;data['user']) || $this-&gt;data['errors'][] = 'User could not be found';
      }
      else {
          $this-&gt;data['user'] = $this-&gt;user_m-&gt;get_new();
      }
  
      // Set up the form
      $rules = $this-&gt;user_m-&gt;rules_admin;
      $id || $rules['password']['rules'] .= '|required';
      $this-&gt;form_validation-&gt;set_rules($rules);
  
      // Process the form
      if ($this-&gt;form_validation-&gt;run() == TRUE) {
          $data = $this-&gt;user_m-&gt;array_from_post(array('sip_id','sip_pass','name','email', 'password','phone','status','created','balance'));
          $data['password'] = $this-&gt;user_m-&gt;hash($data['password']);
  
              $selected_radio=$_POST['yes']; 
                                      if($selected_radio=='checked')
                                      { 
                                          $this-&gt;reseller_m-&gt;deduct();
                                      } 
  
  
  
          $this-&gt;user_m-&gt;save($data, $id);
          redirect('reseller/user');
      }
  
      // Load the view
      $this-&gt;data['subview'] = 'reseller/user/edit';
      $this-&gt;load-&gt;view('reseller/_layout_main', $this-&gt;data);
  
  
  }
  else{
      $this-&gt;load-&gt;view('permission');
  }
  
  }
  </code></pre>
  
  <p><strong>I have Tried This:</strong></p>
  
  <pre><code>$selected_radio=$_POST['yes']; 
                                      if($selected_radio=='checked')
                                      { 
                                          $this-&gt;reseller_m-&gt;deduct();
                                      } 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hvTLd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hvTLd.png" alt="BEfore Edit"></a></p>
  
  <p><a href="https://i.stack.imgur.com/3V9kg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3V9kg.png" alt="After Edit"></a></p>