Data from PHP form is not posting to mySQL : <p>I am a novice with coding, so I am unsure why I am not getting data to store in mySQL after submitting a form. I started with a code generator, but it just ins't working. Thanks for any help.  Here is my code:</p>

<p>Form:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;body&gt;
    &lt;form id="FormName" action="added.php" method="post" name="FormName"&gt;
    &lt;table width="448" border="0" cellspacing="2" cellpadding="0"&gt;

    &lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="name"&gt;Name of Farm    &lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="name" name="name" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="owners"&gt;Name of Owners&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="owners" name="owners" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="location"&gt;Location (city,state)&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="location" name="location" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="phone"&gt;Phone&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="phone" name="phone" type="text" size="25" value="" maxlength="10"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="email"&gt;Email&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="email" name="email" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="website"&gt;Website&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="website" name="website" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="description"&gt;Description&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;textarea id="description" name="description" rows="4" cols="40"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="dateadded"&gt;Today's Date&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="dateadded" name="dateadded" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="logo"&gt;Logo&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="logo" name="logo" type="text" size="25" value="" maxlength="255"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width = "150"&gt;&lt;div align="right"&gt;&lt;label for="state"&gt;State&lt;/label&gt;&lt;/div&gt;&lt;/td&gt;

&lt;td&gt;&lt;input id="state" name="state" type="text" size="25" value="" maxlength="2"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width="150"&gt;&lt;/td&gt;&lt;td&gt;

&lt;input type="submit" name="submitButtonName" value="Add"&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

PHP is in 2 files - one with db connection instructions and the other to post the data in the mySQL.


**Code to Connect to mySQL:**

&lt;?php

$hostname='localhost'; //// specify host, i.e. 'localhost'
$user='llamabre_visitor'; //// specify username
$pass='llama'; //// specify password
$dbase='llamabre_farms1'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass") 
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?&gt;

&lt;a href="index.php"&gt;Back to List&lt;/a&gt;


**Code for posting to mySQL:**

&lt;?php

include("connect.php");

$name = trim($_POST['name']);
$owners = trim($_POST['owners']);
$location = trim($_POST['location']);
$phone = trim($_POST['phone']);
$email = trim($_POST['email']);
$website = trim($_POST['website']);
$description = trim($_POST['description']);
$dateadded = trim($_POST['dateadded']);
$logo = trim($_POST['logo']);
$state = trim($_POST['state']);

$query = "INSERT INTO farmsdir (id, name, owners, location, phone, email, website, description, dateadded, logo, state)

VALUES ('', '$name', '$owners', '$location', '$phone', '$email', '$website', '$description', '$dateadded', '$logo', '$state')";

$results = mysql_query($query);

if ($results)
{
  echo "Details added.";
}
mysql_close();
?&gt;</code></pre>
</div>
</div>
</p>
