Note that there are some explanatory texts on larger screens.

plurals
  1. POSend html form data to sql database via php (using mysqli)
    text
    copied!<p>I want to send the data inputted into an html form to my sql database, i.e., create a new row attributing certain values to certain columns. I know there are similar questions, I read the answers but nothing seems to work.</p> <p>send_post.php</p> <pre><code>&lt;?php //Connecting to sql db. $connect = mysqli_connect("my host","my user","my passwrod","my db"); //Sending form data to sql db. mysqli_query($connect,"INSERT INTO posts (category, title, contents, tags) VALUES ('$_POST[post_category]', '$_POST[post_title]', '$_POST[post_contents]', '$_POST[post_tags]')"; ?&gt; </code></pre> <p>post.html#form</p> <pre><code>&lt;form onSubmit="send_post.php" method="post"&gt; &lt;h3&gt;Category:&lt;/h3&gt; &lt;input type="text" name="post_category"&gt; &lt;h3&gt;Post title:&lt;/h3&gt; &lt;input type="text" name="post_title"&gt; &lt;h3&gt;Post tags (a,b,c...):&lt;/h3&gt; &lt;input type="text" name="post_tags"&gt; &lt;h3&gt;Post (use html):&lt;/h3&gt; &lt;textarea rows="20" cols="50" name="post_contents"&gt;&lt;/textarea&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre> <p>my db "posts" table colums:</p> <pre><code>pid title contents tags category </code></pre> <p><code>pid</code> has <code>auto_increment</code> on</p> <p>I have already tried sending values to all colunes, including <code>pid</code>, and in the "right" order.</p> <p>The <code>mysqli_connect</code> part isn't the issue since I copied it from a different .php file of mine that works.</p> <p>Server php-sql compatibility isn't the issue either, since I successfully had a different .php file retrieve data from the db (data which was manually inserted).</p>
 

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