Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert to database using php?
    primarykey
    data
    text
    <p>I'm very new to php and I really want to learn it. I'm learning from w3school, but I can't manage to do this (saving to database)... I also tried specifying the values in the .php and managed not to get error but it did not save in the database. Please tell me what is wrong in this.</p> <pre><code>&lt;form action="submit.php" method="POST"&gt; &lt;p&gt;Name:&lt;input type="text" name="name"/&gt;&lt;/p&gt; &lt;p&gt;Email:&lt;input type="text" name="email"/&gt;&lt;/p&gt; &lt;p&gt;Message:&lt;textarea rows="3" cols="1" name="message"&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;a href="submit.php"&gt;Submit&lt;/a&gt; &lt;/form&gt; </code></pre> <hr> <p>PHP File</p> <pre><code>&lt;?php $con = mysqli_connect("localhost","root","","kellywood"); if (mysqli_connect_errno()) { echo "Failed to connect to Database"; } else { echo "Connected"; } $sql = "INSERT INTO kellywood (messages.name, messages.email, messages.message) VALUES ('$_POST[name]','$_POST[email]','$_POST[message]')"); if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } mysqli_close($con); ?&gt; </code></pre> <h2>No error, and I specified the values but it did not save in the database.</h2> <pre><code>&lt;?php $con = mysqli_connect("localhost","root","","kellywood"); if (mysqli_connect_errno()) { echo "Failed to connect to Database"; } else { echo "Connected"; } mysqli_query($con,"INSERT INTO kellywood(messages.name, messages.email, messages.message) VALUES ('Peter', 'Griffin',35)"); mysqli_close($con); ?&gt; </code></pre> <p>Sorry for the noob question but i'm very new in php... Please help</p>
    singulars
    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