title: HTML form and PHP function to save form data to mysql in same file/page
body: <p>I won't purport to know exactly what I am doing with this because I don't and that's probably painfully obvious.  I am trying to keep the form and the function to update the database in the same file.  What am I doing wrong?</p>
  
  <p>Here are the important bits:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form id="billing" action="?updatebilling" method="post"&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;!-- Function to update billing --&gt;
  &lt;?php 
  function updatebilling() {
      // Connecting to the MySQL server
      $host="localhost";
      $user_name="root";
      $pwd="bluebox";
      $database_name="rewired";
      $db=mysql_connect($host, $user_name, $pwd) or die(mysql_error());
      if (mysql_error() &gt; "") print mysql_error() . "&lt;br&gt;";
      mysql_select_db($database_name, $db);
      if (mysql_error() &gt; "") print mysql_error() . "&lt;br&gt;";
  
      // Static info - account number
      $account_id=users::getAttr('Account', 'account_id');
  
      // Storing form values into PHP variables
      $zip = mysql_real_escape_string($_POST['billingzip']);
      $name = mysql_real_escape_string($_POST['name']);
  
  
      // Inserting variables into database
      $sql = "INSERT INTO `web_signup`
        SET `account_id` = '{$account_id}',
       `zip` = '{$billingzip}',
       `cardholder_name` = '{$name}',
       `updated_at` = NOW()";
  
      $result = mysql_query($sql) or die(mysql_error().$sql);
  
      mysql_close($db);
  
  }   ?&gt;
  </code></pre>