email after saving to database
<p>Hi i have a fom with a drop down box and a textbox, the drop down box has usernames and emails as their value. I have code that save to the database and code to email but now when it saves to the database the username is not stored only the text in the textbox, please let me know what i am doing wrong I want it to save first then send out an email to the user.</p>

<pre><code>     $con = mysql_connect("host","user","password");
     if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

      mysql_select_db("database", $con);

  $sql="INSERT INTO table(`feild1`, `feild2`)
    VALUES
    ('$_POST[User]','$_POST[QueryDes]')";
     if (!mysql_query($sql,$con))
       {
       die('Error: '. mysql_error());
       }
       echo "1 record added";
</code></pre>

<p>the above code is to insert.</p>

<pre><code>     if (isset($_POST['dropdown']))
     {
       //send email
       $email = $_POST['dropdown'] ;
       $subject = "You have submitted your query  ";
        $message = "Thank you for using the online query facility. We will attend to your query as soon as possible."; 


        $from = "me@mail.com";
      $headers = "From:" .$from;
     mail($email, $subject,$message, $headers);
</code></pre>

<p>and this code above is to send the email. </p>

<pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0           Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
   &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;

   &lt;head&gt;
   &lt;meta content="en-za" http-equiv="Content-Language" /&gt;
  &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
  &lt;title&gt;Query&lt;/title&gt;
  &lt;/head&gt;

  &lt;body&gt;

     &lt;form action="log2.php" method="post"&gt;
UserName&amp;nbsp; &lt;select name="User" style="width: 156px"&gt;
&lt;option value=""&gt;--SELECT--&lt;/option&gt;
&lt;option value="myself@mymail.com"&gt;Me&lt;/option&gt;
      Query Description&amp;nbsp;&lt;input name="QueryDes" style="width: 196px" type="text" /&gt;&amp;nbsp;
      &amp;nbsp;&lt;input name="Submit1" type="submit" value="Log Call" style="width: 78px" /&gt;
      &lt;/form&gt;

      &lt;/body&gt;

   &lt;/html&gt;
</code></pre>

<p>This is the html of the form</p>
