dearmoawiz Posted April 16, 2008 Share Posted April 16, 2008 just put them in Radio button and write this condition if(isset($_REQUEST['rd1'])) { $fldcategory=$_REQUEST['cboCategory1']; $sql ="INSERT INTO tbltextpageseng (cat_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')"; dbQuery($sql); $sql2 ="INSERT INTO tbltextpagesswedish (cat_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')"; dbQuery($sql2); } if(isset($_REQUEST['rd2'])) { $fldcategory=$_REQUEST['cboCategory2']; $sql ="INSERT INTO tbltextpageseng (tp_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')"; dbQuery($sql); $sql2 ="INSERT INTO tbltextpagesswedish (tp_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')"; dbQuery($sql2); } Quote Link to comment Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 Ouch $_REQUEST bad, $_POST good Could you post the error and the form too, we don't know off hand what the problem actually is Quote Link to comment Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 Here is a tidier version of what you have done, <?php if(isset($_POST['rd1'])) { $fldcategory = mysql_real_escape_string($_POST['cboCategory1']); $sql ="INSERT INTO tbltextpageseng (cat_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')"; dbQuery($sql); $sql ="INSERT INTO tbltextpagesswedish (cat_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')"; dbQuery($sql); } if(isset($_POST['rd2'])) { $fldcategory = mysql_real_escape_string($_POST['cboCategory2']); $sql ="INSERT INTO tbltextpageseng (tp_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')"; dbQuery($sql); $sql ="INSERT INTO tbltextpagesswedish (tp_id, pagename, preamble, fldtext) VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')"; dbQuery($sql); } ?> You should use POST or GET instead of REQUEST in almost all situations, REQUEST data could come from any source. I have got rid of the $sql2 statements because you can just reassign the value $sql after your first dbQuery($sql) function, it won't interfere with the previous statement or execution. I also added some escaping on your POST data because you should always perform some sort of data validation especially if your placing that into an SQL statement. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.