Note that there are some explanatory texts on larger screens.

plurals
  1. POForm and PHP function to save form data to mysql in same file
    primarykey
    data
    text
    <p>I have been trying to sort this out but so far I haven't been able to get it to work. No errors are thrown, the page refreshes on submit. I am at a loss, but I am not exactly an expert, fairly new to this. </p> <p>Here is the code (simplified for posting):</p> <pre><code>&lt;?php if (!isset($_POST['submit'])) { echo "&lt;!-- Form starts here --&gt; &lt;form id=\"billing\" action=\"\" method=\"post\"&gt; &lt;!-- Name --&gt; &lt;div class=\"control-group\"&gt; &lt;label class=\"control-label\"&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/label&gt; &lt;div class=\"controls\"&gt; &lt;input type=\"text\" id=\"name\" name=\"name\" placeholder=\"your name\" class=\"input-large\"&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Zip --&gt; &lt;div class=\"control-group\"&gt; &lt;label class=\"control-label\"&gt;&lt;b&gt;Zip Code&lt;/b&gt;&lt;/label&gt; &lt;div class=\"controls\"&gt; &lt;input type=\"text\" id=\"billingzip\" name=\"billingzip\" placeholder=\"5 digit zip\" class=\"input-large\"&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Submit --&gt; &lt;div class=\"control-group\"&gt; &lt;div class=\"controls\"&gt; &lt;button class=\"button save small_green_button\" type=\"submit\"&gt; &amp;nbsp;Save&amp;nbsp; &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt;"; } else { $host="localhost"; $user_name="user"; $pwd="password"; $database_name="database"; $db=mysql_connect($host, $user_name, $pwd) or die(mysql_error()); $dbsel=mysql_select_db($database_name, $db); if (mysql_error() &gt; "") print mysql_error() . "&lt;br&gt;"; if (mysql_error() &gt; "") print mysql_error() . "&lt;br&gt;"; $account_id = users::getAttr('Account', 'account_id'); $zip = mysql_real_escape_string($_POST['billingzip']); $name = mysql_real_escape_string($_POST['name']); $sql = "INSERT INTO `billing` SET `account_id` = '{$account_id}', `zip` = '{$billingzip}', `name` = '{$name}', `updated_at` = NOW()"; $result = mysql_query($sql, $dbsel) or die(mysql_error().$sql); mysql_close($db); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload