Hi everyone,
I'm a complete newbie here. I've looked around for help and tried a few solutions without success, so because time is short I'm asking for help.
I have a registration form which includes address details. The form holds a country field which is a listbox, the values being selected from a MySQL table. How do I assign the selected country option to a field list in the insert statement?
Here's what I have so far:
Registration page form:
<div class="form-group">
<input type="text" class="form-control" id="country" name="country" placeholder="Country">
<select name="country_list">
<?php
$sql = mysql_query("SELECT country_name FROM countries");
while ($row = mysql_fetch_array($sql)){
echo "<option value=\"country_list\">" . $row['country_name'] . "</option>";
}
?>
</select>
</div>
The insert function page:
switch ($action) {
case 'signup':
switch ($action) {
case 'signup':
$country = clean($_POST['$selectedOption']);
etc.
The insert statement:
$sql_insert = "INSERT INTO user_mst(country)
VALUES('$country_name)";
$result_insert = mysql_query($sql_insert) or die(mysql_error());
$id = mysql_insert_id($conn);
In the code sections above, I've removed some of the other fields etc. to focus on the one bit I don't know howto fix.
Thanks in advance for any help.