Jump to content

Changing Radio Button option to variable


mikebyrne

Recommended Posts

I want it to when the user selects "Show" the word YES will pass to the Display field in my databasae and f the user selects "Hide" the words NO will pass to the dispaly fields

 

At present my PHP looks like

 

<?PHP

require_once("adminconnect.php");

$ProductNo = mysql_real_escape_string(trim($_POST['ProductNo']));
$ProductName = mysql_real_escape_string(trim($_POST['ProductName']));
$Description = mysql_real_escape_string(trim($_POST['Description']));
$Price = mysql_real_escape_string(trim($_POST['Price']));
$Stockamount = mysql_real_escape_string(trim($_POST['Stockamount']));
$Type = $_POST['Type'];

$tbl_name="product";

$sql="INSERT INTO $tbl_name (Producttype, ProductNo, ProductName, Description,Price) VALUES ('$Type','$ProductNo', '$ProductName', '$Description', '$Price')";
mysql_query($sql);

echo $_POST['ProductNo'];
echo $_POST['ProductName'];
echo $_POST['Description'];
echo $_POST['Price'];
echo $_POST['Stockamount'];
echo $_POST['Type'];
echo $sql;

?>

 

 

<div class="editRightText">Display:</div>
              <div class="editRightForm">
                <div class="editRadio1">
                  <input name="display" type="radio" value="yes" checked="checked" />
                </div>
                <div class="editRadio2">show</div>
                <div class="editRadio3">
                  <input name="display" type="radio" value="no" />

Link to comment
https://forums.phpfreaks.com/topic/97355-changing-radio-button-option-to-variable/
Share on other sites

Is it enough ?

..
$Disp = mysql_real_escape_string(trim($_POST['display']));
..
..
$sql="INSERT INTO $tbl_name (Producttype, ProductNo, ProductName, Description,Price,Display) VALUES ('$Type','$ProductNo', '$ProductName', '$Description', '$Price', '$Disp')";
..
..
echo $_POST['display'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.