PHP/MySql begginer-putting data to table
<p>ok so im learning to put values into my db from php.
this is my simple form i wrote to test (its in a table)</p>

<pre><code>&lt;form action="connect2db.php" method="post"&gt;
&lt;table width="500" border="0"&gt;
    &lt;tr&gt;
        &lt;td width="200"&gt;first name:&lt;/td&gt;
        &lt;td&gt;&lt;input type="text" width="258" name="fname" id="fname"/&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td width="200"&gt;last name:&lt;/td&gt;
        &lt;td&gt;&lt;input type="text" width="258" name="lname" id="lname"/&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;
        your email address: 
        &lt;/td&gt;
        &lt;td&gt;
        &lt;input type="text" width="258" name="email" id="email"/&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td width="200"&gt;Your message:&lt;/td&gt;
        &lt;td&gt;&lt;textarea rows="5" cols="45" name="mssg" id="mssg" &gt;&lt;/textarea&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;input type="submit"&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>everything works as far as page 1 sending the values to page 2, and echoing them out. but
when its time to insert them into the db table. its not working.
this is the php code:</p>

<p>when i do a SELECT * FROM <em>myTableNameHere</em>, it says "empty set", when i enter the values manually via terminal to test, i get the values fine.</p>

<p>here is my simple code:</p>

<pre><code>&lt;?php 
$connection = mysql_connect("127.0.0.1","root","passhere"); 
if(!$connection) {
    die("database connection failed you fool!: FIX IT!" . mysql_error()); } 


$db_select = mysql_select_db("storeemail",$connection);
if(!$db_select){
    die("database selection failed." . mysql_error()); }
    else{ echo "connection made ";
    }

?&gt;

&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;


&lt;?php
$to = 'email@gmail.com';
$subject = 'test from my email php script';
$email = $_POST['email'];
$name = $_POST['fname'];
$lastname = $_POST['lname'];
$mssg = $_POST['mssg'];


$insertData = mysql_query("INSERT into myusers(firstname, lastname) 
VALUES ('$name', '$lastname', '$email', '$mssg');");


 mysql_close($connection) 

?&gt;&lt;br/&gt;

your first name is - &lt;?php echo $name; ?&gt;&lt;br/&gt;
your last name is - &lt;?php echo $lastname ; ?&gt;&lt;br/&gt;
your message to send is - &lt;?php echo $mssg; ?&gt; &lt;br/&gt;




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

<p>Thanks in advance.</p>
