I've got a profile page that shows a users current account number in an input field. The user can change this account number and submit the form to update the database with their new account number.
What I need to do is get the initial account number, as well as the new submitted account number so I can use them in another script that runs on the same page.
$user = Am_Di::getInstance()->auth->getUser();
$oldnum = $user->accountnumber;
$newnum = $_GET['accountnumber'];
$client2 = $api->findClient( mlApi::LICENSE_ACCOUNT, $oldnum );
$client = array( 'account_no' => $newnum, 'real_demo' => '1', 'comment' => 'test2' );
$api->updateClient( mlApi::LICENSE_ACCOUNT, $client2[_index], $client );
If you want to keep a value saved for future use there is two common ways (could be other ways) of handling it.
The latter has a 100% security problem because a malicious user can change this id before the next request comes. To demonstrate how
<input type='hidden' name='account_id' value='<?php echo $account?>' />
<input type='text' name='account_id_text' value='<?php echo $account?>' />
This method use is highly discouraged.
The first method, using the session is the safest mechanism of all.
To utilize that
$_SESSION['account_id'] = $account_id;
//render the view here
I hope this answers your question.