I don't get it. can anyone help me with this ? It's a simple preceding
checkbox, either yes or no - if yes, add the details to a $db and if
no, then don't. But I get the original variable being switched from
yes to no, or from no to yes, and either way, the database gets
accessed.
(code page1)
(snip)
<SELECT NAME="radiobutton" SIZE="1"><OPTION VALUE="yes" selected>yes
please</OPTION><OPTION VALUE="no">no thanks</OPTION></SELECT>
(/snip)(code)
(code page2)
-----------
$cname = $_POST['cname'];
$sname = $_POST['sname'];
$radio = $_POST['radiobutton'];
//collect the radio value
$mail = "";
$mail=$radio;
// see what I've got
echo $mail;
//then it is supposed to be yes or no and act accordingly
if ($mail = "yes") {
// stick into database
$host = "(host)";
$login_name = "(name)";
$password = "(password)";
MySQL_connect("$host","$login_name","$password");
MySQL_select_db("(database") or die("Could not select database");
$sql = "INSERT INTO (table) ( cname, sname) VALUES
('$cname','$sname')";
// save the result for later on
$result = mysql_query($sql);
if ($result) {
$post = "Yes, thanks";
} else {
$post = "No";
}
}
// checking what I've got
echo $mail;
(/code)