/    Sign up×
Community /Pin to ProfileBookmark

Storing radio button variables in mysql – "for dummies"

There are quite a few posts on Google regarding this subject, but it’s comparable to reading Japanese :-p I just need a straight forward explanation on how to store my radio button option to mysql database and have that selection stay selected when the user logs back in.

Below is the radio button excerpt from my form:

<td width=”24″><span class=”med”>
<input type=”radio” name=”quotationinsurance” value=”<?php
if($form->value(“quotation”) == “”){
echo $session->userinfo[‘quotation’];
}else{
echo $form->value(“quotation”);
}
?>” class=”btn” onMouseOver=”hov(this,’btn btnhov’)” onMouseOut=”hov(this,’btn’)” />
</span></td>
<td width=”54″><span class=”small”>Insurance</span></td>
<td width=”271″><span class=”med”>
<input type=”radio” name=”quotationinsurance” value=”<?php
if($form->value(“insurance”) == “”){
echo $session->userinfo[‘insurance’];
}else{
echo $form->value(“insurance”);
}
?>” class=”btn” onMouseOver=”hov(this,’btn btnhov’)” onMouseOut=”hov(this,’btn’)” />
</span></td>

Below is the php:

function procEditFormOne(){
global $session, $form;
/* form one edit attempt */
$retval = $session->editFormOne($_POST[‘quotationinsurance’], $_POST[‘businessofapplicant’], $_POST[‘individuals’], $_POST[‘corporation’], $_POST[‘parnternship’], $_POST[‘other’], $_POST[‘requestedfrom’], $_POST[‘requestedto’]);

/* Form one edit successful */
if($retval){
$_SESSION[‘subFormOneEdit’] = true;
header(“Location: “.$session->referrer);

}
/* Error found with form */
else{
$_SESSION[‘value_array’] = $_POST;
$_SESSION[‘error_array’] = $form->getErrorArray();
header(“Location: “.$session->referrer);
}

}

Below is the column structure ‘quotationinsurance’ for the database table named user:

Column: quotationinsurance
Type: SET
Length/Values: ‘quotation’,’insurance’
Default: None

Every time I make a selection and click the save/submit button, the selection disappears. I’m not sure what I’m really doing wrong; Just need a straight forward; preferably slow explanation 🙂

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @swalker-1974 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...