Updating user record outside of CMS ?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 3, 2012   (RSS)

Re: [nmsinc] Updating user record outside of CMS ?

By (Deleted User) - April 3, 2012

Hello nmsinc,

The best solution would be to send the user number as a hidden field (like the 'save' field) rather than directly through the url.

This will leave your code much cleaner and much easier to read/update:

<form method="post" action="user-profile-admin-update.php">

<input type="hidden" name="save" value="1" />

<input type="hidden" name="num" value="<?php echo $accountsRecord['num']; ?>" />


Then when you are retrieving the record for the update, you can check if the 'num' has been passed in POST. If it has, use that num to search for the user info. If not, default to the 'whereRecordNumberInUrl' function:

$where = whereRecordNumberInUrl(1);
if ( @$_REQUEST['num'] ) { $where = "num='".$_REQUEST['num']."'"; }

list($accountsRecords, $accountsMetaData) = getRecords(array(

'tableName' => 'accounts',

'where' => $where,

));

$accountsRecord = @$accountsRecords[0]; // get first record


You don't have to refer to the user number as 'num', you can call it whatever you want - I just used num because that's the easiest thing to remember!

Hope this helps,

Tom

Re: [Tom P] Updating user record outside of CMS ?

By nmsinc - April 3, 2012

Hi Tom,

Worked - Thanks!
nmsinc