Pass variables through AJAX callback and update MySQL database I have a form where the users submit a text. Here is the code:

$form['reason'] = array(
            '#type' =&gt; 'textfield',
            '#title' =&gt; '',
            '#size' =&gt; '200',
            '#attributes' =&gt;array('placeholder' =&gt; t('*Reason')),
            '#prefix' =&gt; '&lt;div&gt;'
          );


    $form['newsletter_unsubscribe_submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; 'Submit',
        '#attributes'=&gt; array(
            'class' =&gt; ['btn', 'btn-primary']
        ),
        '#ajax' =&gt; array(
            'callback' =&gt; 'newsletter_unsubscribe_quiz_submit_driven_callback_share',
            'method' =&gt; 'replace',
            'effect' =&gt; 'fade',
        ),
        '#prefix' =&gt; '&lt;div class="regular newsletter_unsubscribe_button"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;&lt;/div&gt;');


    return $form;


I managed to get the input of the user on a variable using $_values = $form_state['values'];
Also, I have some other variables to read from the current path and get some values.

    $_path = $_SERVER['HTTP_HOST'] . request_uri();

    preg_match('~id=(.*?)&amp;~', $_path, $id);

    $first = $id[1];
    $second = substr($_path, -5);


where the first is the user id and the second is another variable that is unique per user.
My only problem is that I can't pass the $first and $second variables through the callback, and have them along with $reason $_reason = filter_xss($_values['reason']);
So, in my callback I want to be able to get the variables $first,$second with the $reason I already have. Now I have the $_path variables above my form, in the same function.
Then I want to perform an update query on MySQL, something like  

UPDATE users SET reason=$reason
WHERE first=$first AND second=$second


where the column users has only the columns first,second and reason . Is this possible? Thanks in advance!  

EDIT
I actually managed to do the first part and get the variables. I created two form inputs and I give them default values, the two variables I want to get, and I will hide them afterwards.
I still haven't figured out how to update MySQL though, so all answers are welcome!
I actually managed to do it! For anyone that may have a similar problem this is what I did.
First of all, I took the url parameters using parse_url and did the following

$parts =  parse_url($_path);
parse_str($parts['query'], $query);
$first = $query['first'];
$second = $query['second'];


,then put those variables as form default values, that I will hide using css:

$form['user_id'] = array (
         '#type' =&gt; 'textfield',
         '#title' =&gt; t('User id'),
         '#description' =&gt; t('user id'),
         '#default_value' =&gt; $first,
);


Then, on my callback function I take those variables, for example:

$_first = filter_xss($_values['first']);


and then I used db_update:

$num_updated = db_update('unsubscribed_users')
    -&gt;fields(array(
        'reason' =&gt; $_reason,
      ))
    -&gt;condition('first', $_first , '=')
    -&gt;condition('second', $_second , '=')
    -&gt;execute();