title: HTML form to POST data to MySQL
body: <p>I'm trying to post data to an MySQL database by using Node.js.</p>
  
  <p>This is my htmlHTML 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;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head lang="en"&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;This is my form&lt;/h1&gt;
  &lt;!-- local host to be changed?  --&gt;
  &lt;form action="http://localhost:3000/index.html" method="POST"&gt;
      First name:&lt;br&gt;
      &lt;input type="text" name="firstname" value="John"&gt;
      &lt;br&gt;
      Last name:&lt;br&gt;
      &lt;input type="text" name="lastname" value="Doe"&gt;
      &lt;br&gt;&lt;br&gt;
      &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And here is my <code>MySQL.js</code>:</p>
  
  <pre><code>var mysql = require('mysql');
  
  var connection = mysql.createConnection(
      {
        host     : 'mysqlhost',
        port     : '3306',
        user     : 'myuser',
        password : 'mypassword',
        database : 'myuser'
      } ); connection.connect(); var query = connection.query('SELECT * FROM http://localhost:3000/index.html');
  
  query.on('error', function(err) {
      throw err; });
  
  query.on('fields', function(fields) {
      console.log(fields); })
  
  query.on('result', function(row) {
      console.log(row); }); connection.end();
  </code></pre>
  
  <p>Is this even possible?</p>