title: Storing input from user into database
body: <p>I am fairly new to PHP and I am trying to save input from a user into a mysql database. I followed a tutorial online on how to do it, but every time I enter the user's info, the website tells me it failed. The only thing that I can think of is the host name(I copied and pasted it from phpadmin).Please let me know if there is something wrong.</p>
  
  <p>contact.html</p>
  
  <pre><code>&lt;section id="mid_section"&gt;
                  &lt;div id="boxes"&gt;
                      &lt;h1&gt;
                          Leave your information here for a quick reponse:
                      &lt;/h1&gt;
                      &lt;br/&gt;
                      &lt;form id="myform" action="userinfo.php" method="post"&gt;
                          Name:&lt;input type="text" value="name"&gt;
                          Email:&lt;input type="email" value="email"&gt;
                          Phone:&lt;input type= "tel" value="phone(opt)"&gt;
                          &lt;button id="sub"&gt;Submit&lt;/button&gt;
                      &lt;/form&gt;
  </code></pre>
  
  <p>db.php</p>
  
  <pre><code>&lt;?php
      $conn = mysql_connect('custsql.eigbox.net','username','password');
      $db= mysql_select_db('visitors');
  ?&gt;
  </code></pre>
  
  <p>userinfo.php</p>
  
  <pre><code>&lt;?php
      include_once('db.php');
  
      $name =$_POST['name'];
      $email =$_POST['email'];
      $phone =$_POST['phone'];
  
      if(mysql_query("INSERT INTO users (name,email,phone) VALUES ('$name','$email','$phone')"))
      echo"successfully inserted";
      else
      echo "failed";
  ?&gt;
  </code></pre>
  
  <p>myscript.js</p>
  
  <pre><code>$("#sub").click(function(){
  
      $.post($("#myform").attr("action"), $("#myform:input").serializeArray(), function(info){$("#result").html(info);});
      });
  
  $("#myform").submit(function(){
      return false;
      });
  </code></pre>