Pass info from page link to form I am trying to build a custom module that uses a theme page to display a list of items withing a table. Each item has a unique ID. and I would like to have links within this table so that my users can preform actions using the uid. The link works and takes you to the form but it doesn't carry over the uid.

Here is the code from my theme file.

&lt;?php

/**
 * @file
 * definition of uc-bitcoin-account-outgoing-escrows.tpl.php.
 */
$user = user_load($variables['uid']);

global $base_url;

$transactions = db_query("SELECT * FROM {uc_btc_escrow_payment} WHERE from_account='$user-&gt;uid'");

$header = array(t('Escrow ID'), t('Amount'), t('Payment'), t('Allocated to'), t('Release'), t('Dispiute'), t('Date'));

$rows = array();

foreach ($transactions as $transaction) {
  $rows[] = array(
      $transaction-&gt;escrow_id, $transaction-&gt;amount, $transaction-&gt;status , $transaction-&gt;to_user, '&lt;a href="' . $base_url . '/user/orders/release-escrow/' . $transaction-&gt;escrow_id . '"&gt;Release Payment&lt;/a&gt;', '&lt;a href="' . $base_url . '/user/funds/dispute-escrow/' . $transaction-&gt;escrow_id . '"&gt;Dispute Payment&lt;/a&gt;', date('d/m/Y   g:i:s A', $transaction-&gt;created)
  );
}

print t('&lt;h2&gt;Outgoing Escrows&lt;/h2&gt;');

print theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows));
?&gt;


When the user clicks on the Release Payment link it will take them to the form I created but it has a few errors. And Doesn't work. Here is the code for that function.

function uc_escrow_release_payment($form, &amp;$form_state, $escrow_id) {

  $form['#$escrow_id'] = $escrow_id;

  $transaction = db_query("SELECT * FROM {uc_btc_escrow_payment} WHERE escrow_id= :escrow_id", array(':escrow_id' =&gt; $escrow_id))-&gt;fetchAssoc();

  $user = user_load($transaction['reference']);
  $to_user = $transaction-&gt;to_user;
  return confirm_form($form, check_plain('Release Escrow Payment?'), 'user/orders', check_plain('Are you sure you want to release this payment and send the funds to ' . $to_user . '?'), check_plain('Yes'));
}


The errors I am getting are because the information isn't getting passed from one page to the other.

Notice: Undefined index: reference in uc_escrow_release_payment()
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController-&gt;load()
Notice: Trying to get property of non-object in uc_escrow_release_payment() 


I think I am missing something small. Thank you for the help.
I thought it easier if I just mark up the code a bit, I've tried to notate where I made changes.  Can you run this and tell us what it does, if it doesn't solve your problem?

&lt;?php

  /**
   * @file
   * definition of uc-bitcoin-account-outgoing-escrows.tpl.php.
   */

  /** clr use $account instead of $user in case global $user is already in scope **/
  $account = user_load($variables['uid']);
  /* also, loading the user seems extraneous if you're not checking
   * anything else (is user valid, is user in a certain role, etc.)
   * if so, you should include an additional check.  If not, just
   *  do your query using $variables['uid']
   */
  global $base_url;

  /** clr drupalized the query **/
  $transactions = db_query("SELECT * FROM {uc_btc_escrow_payment} WHERE from_account=:user_id", array(':user_id' =&gt; $account-&gt;uid));

  $header = array(t('Escrow ID'), t('Amount'), t('Payment'), t('Allocated to'), t('Release'), t('Dispiute'), t('Date'));

  $rows = array();

  /** clr adding a check here **/
  if (!$transactions) {
    die('No Transactions were found');
  }
  /** clr clean up the anchor tags **/
  foreach ($transactions as $transaction) {
    $release_href = $base_url . '/user/orders/release-escrow/' . $transaction-&gt;escrow_id;
    $dispute_href = $base_url . '/user/funds/dispute-escrow/' . $transaction-&gt;escrow_id;
  $rows[] = array(
    $transaction-&gt;escrow_id, 
    $transaction-&gt;amount, $transaction-&gt;status , $transaction-&gt;to_user, 
    l('Release Payment', $release_href),
    l('Dispute Payment', $dispute_href),
    date('d/m/Y   g:i:s A', $transaction-&gt;created)
  );
}

print t('&lt;h2&gt;Outgoing Escrows&lt;/h2&gt;');

print theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows));
?&gt;


And then your function:

function uc_escrow_release_payment($form, &amp;$form_state, $escrow_id) {

/** check $escrow_id **/
if (!$escrow_id || $escrow_id == '') {
  die('Do something here, because you don\'t have everything you need');
}

/** clr not sure why '$' is used in $form key? */
$form['#$escrow_id'] = $escrow_id;

/** clr changed to fetch object **/
$transaction = db_query("SELECT * FROM {uc_btc_escrow_payment} WHERE escrow_id=:escrow_id", array(':escrow_id' =&gt; $escrow_id))-&gt;fetchObject();
/** check transaction **/
if (!$transaction) {
  die('No transaction was found; In ' . __FUNCTION__);
}
/** clr don't use $user for same reason above **/
$account = user_load($transaction-&gt;reference);
$to_user = $transaction-&gt;to_user;
/** check_plain() is only necessary when you're dealing with user supplied text. 
 *  that being said, I guess it never hurt to be over cautios */
return confirm_form($form, check_plain('Release Escrow Payment?'), 'user/orders', check_plain('Are you sure you want to release this payment and send the funds to ' . $to_user . '?'), check_plain('Yes'));
}