POPULATE A SIGNUP AND PROFILE REVISION FORM WITH EXISTING RADIO BUTTONS VALUE - Feb 18th, 2011


Let’s say you’ve got a radio button field called “interest” on your profile form with a number of possible
values and you want to echo the current value from your user's record in their profile revision form.

It’s easy when you follow these 3 simple steps:

- Add a field to your User Accounts editor. (For this example
we'll call your field 'interest')

- Add this error checking code to your signup.php or profile.php viewer:

if (!@$_REQUEST['interest']) { $errorsAndAlerts .= "You must select your interest!\n"; }


- Add this code to the list of mysql queries:

interest = '".mysql_escape( $_REQUEST['interest'] )."',


- Add this user input field to your form:

<tr>
<td valign="top">Interest</td>
<td>
<?php $fieldname = 'interest'; ?>
<?php $idCounter = 0; ?>
<?php foreach (getListOptions('accounts', $fieldname) as $value => $label): ?>
<?php $id = "$fieldname." . ++$idCounter; ?>
<input type="radio" name="<?php echo $fieldname ?>" id="<?php echo $id ?>"
value="<?php echo htmlspecialchars($value) ?>" <?php checkedIf(@$_REQUEST[$fieldname], $value) ?> />
<label for="<?php echo $id ?>"><?php echo htmlspecialchars($value) ?></label>

<?php endforeach ?>
</td>
</tr>


- Before you go “live”, test that the form lets you save each possible value, displays the last saved
value, and that saved values are also displayed correctly in the User Accounts record.



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service