checkbox selection script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mindsoul
Forum Newbie
Posts: 4
Joined: Tue Aug 17, 2004 11:02 pm
Location: romania
Contact:

checkbox selection script

Post 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') ";}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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";
mindsoul
Forum Newbie
Posts: 4
Joined: Tue Aug 17, 2004 11:02 pm
Location: romania
Contact:

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
mindsoul
Forum Newbie
Posts: 4
Joined: Tue Aug 17, 2004 11:02 pm
Location: romania
Contact:

Post 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???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes, the data will be mixed together.. you'll have to extract what you need for each insert/update
mindsoul
Forum Newbie
Posts: 4
Joined: Tue Aug 17, 2004 11:02 pm
Location: romania
Contact:

Post 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??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

correct.. roughly...:?
Post Reply