Jump to content

[SOLVED] Radio Group Not Saving Value in DB


CyberWoolf

Recommended Posts

I'm hoping someone can help me out here.  I am stumped.  I cannot get my radio group to save to mysql db.  All the other fields will save fine.  If I enter the value manually in the db, it works but will not save.  It actually clears the info in there  ???

 

FORM

 


switch($sc_address_btn) 
{ 
   case "addy1": $checkaddy1 = "checked"; break; 
   case "addy2": $checkaddy2 = "checked"; break; 
   case "addy3": $checkaddy3 = "checked"; break; 
}

<table width="250" border="0" cellpadding="0" cellspacing="0" class="form">
  <form id="form1" name="form1" action="form.php" method="POST">
    
    <tr>
      <td width="74">Address 1<br />
          <input type="radio" name="sc_address_btn" value="addy1" <?=$checkaddy1 ?> >      </td>
      <td width="176" colspan="2"><textarea name="Address" rows="4" class="single" id="Address">some addy 1</textarea></td>
    </tr>
    <tr>
      <td width="74">Address 2<br />
          <input type="radio" name="sc_address_btn" value="addy2"  <?=$checkaddy1 ?> >      </td>
      <td colspan="2"><textarea name="Address2" rows="4" class="single" id="Address2">addy3</textarea></td>
    </tr>
    <tr>
      <td width="74">Address 3<br />
          <input type="radio" name="sc_address_btn" value="addy3"  <?=$checkaddy1 ?> >      </td>
      <td colspan="2"><textarea name="Address3" rows="4" class="single" id="Address3">addy2</textarea></td>
    </tr>
    
    
    <tr>
      <td width="74"> </td>
      <td colspan="2" align="left" style="margin:10px 0 0 0;"><input style="width:145px;" type="submit" name="submit" id="submit" value="Submit">      </td>
    </tr>
    <tr>
      <td width="74"> </td>
      <td colspan="2"> </td>
    </tr>
  </form>
  </div>
  
</table>

 

PHP

 

My post

 

$sc_address_btn = $_POST["sc_address_btn"];

Link to comment
Share on other sites

no.. its not taking info from another page.  Just the one page and the form.php file to post the data and send an email.  :-/

 

echo "sc_address_btn = {$_POST['sc_address_btn']}";

 

I tried doing that, but it didn't help.  I tried it at after the submit button and then on the form.php file too

 

Thanks for responding so quick :-)

Link to comment
Share on other sites

At the start of your processing script add:

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>

 

This will show what is being passed to the script from the form.

 

I also noticed you're using short tags "<?=" to echo the values, try using "<?php echo" instead.

 

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.