Search code examples
phphtmldropdownlistfor

I don't see my dropdown list value in my database


I made a dropdown list with countries, and I want to save the selected country to the database. But I dont see it in my database. I made a sample label for text (proba), and this is working, I can see it in my database. Can somebody help me, why can I not see the countries in my database?

<div  style="position:absolute;top:45%;left:150%"  class="styled"  name='country' id='country' value='<?php echo $fgmembersite->SafeDisplay('country') ?>' >

    <SELECT >
<OPTION SELECTED> Country
<OPTION value="afghanistan"> Afghanistan </option>
<OPTION value="albania"> Albania </option>
<OPTION value="algeria"> Algeria </option>
<OPTION value="andorra"> Andorra </option>
<OPTION value="angola"> Angola </option> 
<OPTION value="antiqua and barbuda"> Antiqua and Barbuda </option>
<OPTION value="argentina"> Argentina </option>
<OPTION value="armenia"> Armenia </option>
</SELECT> 
</div>

<div style="position:absolute;top:70%;left:150%" >
    <label for='proba' ></label><br/>
    <input type='text' name='proba' id='proba' value='<?php echo $fgmembersite->SafeDisplay('proba') ?>' maxlength="50" placeholder="proba"/><br/>

</div>

and with this code I want to insert the data to my database

 $insert_query = 'insert into '.$this->tablename.'(
                name,
                email,
                username,
        country,
                proba,
                password,
                confirmcode
                )
                values
                (
                "' . $this->SanitizeForSQL($formvars['name']) . '",
                "' . $this->SanitizeForSQL($formvars['email']) . '",
                "' . $this->SanitizeForSQL($formvars['username']) . '",
                "' . $this->SanitizeForSQL($formvars['country']) . '",
                "' . $this->SanitizeForSQL($formvars['proba']) . '",
                "' . md5($formvars['password']) . '",
                "' . $confirmcode . '"
                )';      

Solution

  • The name attribute is on the wrong element, so it has no effect. Move name='country' from the <div> to the <select>.