mercredi 29 juin 2016

Radio buttons updating a database deletes the entry?

so I'm creating a small form where you can update the values of some fields pulled from a database.

Two of the fields I have however are acting wrong, when the page loads they display the information correctly but when you press 'submit' the fields in the MySQL table go blank. All the other fields update correctly including a checkbox, but not these two radio buttons.

Here's the code for it, I'm sorry to be asking this but does anyone see the error? I'm rather new with PHP so I'm not sure what to look for.

Snippet of the PHP Code (I can post the full code of it, but it's long):

<?php 

  if(isset($_POST['submit'])) { 
  $mbr=$_POST['mbr'];
  $rec=$_POST['rec']; 

  $update = $dbconnect->query("UPDATE testing SET mbr='$mbr', rec='$rec'");
  } 

  ?>

HTML Code for the 2 radio buttons:

<input type="radio" name="mbr" <?php echo $upChecked; ?>>Up <input type="radio" name="mbr" <?php echo $downChecked; ?>>Down

<input type="radio" name="rec" <?php echo $yesChecked; ?>>Yes <input type="radio" name="rec" <?php echo $noChecked; ?>>No

Aucun commentaire:

Enregistrer un commentaire