This is a discussion on my code erronousely changes the variable within the PHP Language forums, part of the PHP Programming Forums category; I don't get it. can anyone help me with this ? It's a simple preceding checkbox, either yes or ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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) |
|
|||
|
george <russell@waiheke.co.nz> wrote:
> 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. > //then it is supposed to be yes or no and act accordingly > if ($mail = "yes") { if ($mail == "yes") { JOn |