PDA

View Full Version : Passing data between PHP and MySQL database?


MacMorag
07-11-2004, 02:34 PM
I have added a drop-down menu to the reply form, which has three options - "A", "B" and "C". Whenever someone replies they must select either of the three options.

I have also created a new field in the "post" table in the database. This field is called "option", and is used to record whether A, B or C was selected when the post was submitted.

How do I pass the selected option from the reply form and place it in the "option" field in the database.

e.g. When the post is submitted by the user, they select option A. How do I place "A" in the "post"table of the database.

Thanks.

AN-net
07-11-2004, 03:00 PM
edit /includes/functions_newpost.php

MacMorag
07-11-2004, 04:31 PM
Thanks AN-net

MacMorag
07-12-2004, 12:14 AM
Still stuck here :ermm:

What do I need to add to /includes/functions_newpost.php to get the selected option written to the database?

The drop down menu on the form has name = "option" and can have a selected value of "A", "B" or "C". How do I get $post[option] to contain the selected value? I'm guessing that it should be something along the lines of:

$post[option] = val(option) - i.e. $post[option] contains the value of "option" passed from the form.

I'm starting php from scratch here, so apologies for what seems like a fairly elementary question.

MacMorag
07-12-2004, 01:02 AM
Sorted :)

If anyone else wants to know - use the $_POST variable which is automatically set by PHP when it encounters a form.