title: Creating a form to submit data into wordpress database
body: <p>I have been trying to come up with some way to get a html form i made on a wordpress page to take the information entered and send it to custom tables in the wordpress database. I have tried calling a custom php script and writing code in the page itself and i cannot not figure out how to get it to work.  I am going crazy trying to figure this out, I am about to give up. Any suggestions on where to start looking, enough i have been searching for a week, would be great. </p>
  
  <p>I have tried using mysqli_connection but i keep getting issue connecting where i put (mysite.com,user,pass,db); and i get another error "cannot connect "user@anotherunknownsite.com" i have a shared ip so i wonder if it is connecting to this other site, which has NO reference in my code. I tired using local host instead of my site but nothing works.</p>
  
  <p>This code tries to get some data off the db but nothing happens, same as b4 where mysite.com shows a error cant connect to user@randomsite.com and localhost doesnt work.</p>
  
  <pre><code> &lt;?php
      $con=mysqli_connect("mysite.com","user","pass","db");
      // Check connection
      if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
  
      $result = mysqli_query($con,"SELECT * FROM Liquor_Type");
  
      while($row = mysqli_fetch_array($result)) {
        echo $row['lq_name'] . " " . $row['description'];
        echo "&lt;br&gt;";
      }
  
      mysqli_close($con);
      ?&gt;
  </code></pre>
  
  <p>my form</p>
  
  <pre><code>&lt;form  action = "setLQType.php" method="post"&gt;
  Add a New Liquor Type&lt;/br&gt;&lt;/br&gt;
  &lt;p&gt;Name: &lt;input type="text" name="name"/&gt;&lt;/p&gt;
  &lt;p&gt;Description &lt;input type="text" name="description"/&gt;&lt;/p&gt;
  ----------------------------------------------
  &lt;input type="submit" name="Submit"/&gt;
  &lt;/form&gt;
  &lt;/br&gt;
  </code></pre>
  
  <p>The setLQType php file, which is in the main wordpress dictionary. It will got to the file but do nothing.</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("mysite.com","user","pass","db_name");
  // Check connection
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $name = mysqli_real_escape_string($con, $_POST['name']);
  $description = mysqli_real_escape_string($con, $_POST['description']);
  
  $sql="INSERT INTO Liquor_Type(lq_name, description)
  VALUES ('$name ', '$description)";
  
  if (!mysqli_query($con,$sql)) {
    die('Error: ' . mysqli_error($con));
  }
  echo "1 record added";
  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>Updated insert page... setLiquorType.php in website.com/setLiquorType.php</p>
  
  <pre><code>&lt;?php 
  $global $wpdb;
  $name = $_POST['name'];
  $description = $_POST['description'];
  $table_name = $wpdb-&gt;prefix . "wp_Liquor_Type";
  $wpdb-&gt;insert($table_name, array(
                              'lq_name' =&gt; $name,
                              'description' =&gt; $description
                              ));
  ?&gt;
  </code></pre>