i have this select box that users can use to choose an option, but im stuck on how i can process it with php and insert the value in mysql:
<select name="vote[]">
<option value="support">I support this</option>
<option value="against">Im against this</option>
<option value="dont">I want the audience to decide!</option>
$insert=mysql_query("INSERT INTO topic (topic, founder, choice, date) VALUES('".$course."', '".$user_id."', '".$_POST['vote[]']."',NOW())");
In addition to what Ben has already said, you want to drop the brackets from the
nameattribute.When you go to retrieve the value, just use
$_POST["vote"]. The use of square brackets is only if you intend to have multiple fields with the same name (i.e.: allowing the user to dynamically generate fields on the fly). You don’t need to use it with dropdowns across the board.EDIT
Also, as your resident PHP guru, I am contractually obligated to remind you to ALWAYS escape ANY data that is inserted into a SQL query. This means vigorously using
mysql_real_escape_string()every time. Only you can prevent forest fires, VD, and god knows what else, but you can only do it if you’re escaping your SQL parameters.