Page 1 of 1

checkbox selection script

Posted: Tue Aug 17, 2004 11:02 pm
by mindsoul
I have a form wich i use to put some text into my database .
I have a table name design and another table name about.
So a want to make in this form 2 checkboxes and when one from this is selected i want that all the data from the form is going in the date base table wich is selected.
I don't now how can i write in php :if ...checkbox1 is selected then
$dbselectata ="value chekbox1"
$query="INSERT INTO $dbselectata (titlu,continut,autor) VALUES ('$titlu','$continut','$autor') ";}

Posted: Tue Aug 17, 2004 11:14 pm
by feyd

Code: Select all

if(isset($_POST['checkboxname']))
{
// one of the check boxes were selected.. lets find out which:
print_r($_POST['checkboxname']);
}
else
  echo "no checkbox found in POST";

Posted: Wed Aug 18, 2004 12:27 am
by mindsoul
thanks for your time.
last question:
how can i store the selected value from check box in a $variable?
or
in your code i think that you already puted into the$_POST????
If is so it remains only to do :
$db_table_selected_name=$post;
Corect me if i mistake.
Thank you very much for your precios time.

Posted: Wed Aug 18, 2004 12:35 am
by feyd
$_POST is a php core superglobal variable where all posted data gets stored... likewise, $_GET is there all get url arguments are stored...

Posted: Wed Aug 18, 2004 12:42 am
by mindsoul
it means that first i store values in and after i can put the value in another variable?
But if the bouth check boxes are selected and i wan to put text in bouth tables design and about???
Are the data puted in the variable $_POST mixted???

Posted: Wed Aug 18, 2004 12:52 am
by feyd
yes, the data will be mixed together.. you'll have to extract what you need for each insert/update

Posted: Wed Aug 18, 2004 12:59 am
by mindsoul
if i have choosed both tables it meens the $_POST is an an array woith 2 elements is'it?
and if i choose one $_POST is an array with only an element??

Posted: Wed Aug 18, 2004 1:09 am
by feyd
correct.. roughly...:?