Today I decided to continue on working with the database which applies the "INSERT" data to the PHP file. This time I try a different way to insert data from the database. I have separated two different files. One is connected to the server another functions for insert data.
By separating two files, the data can be inserted successfully.
Therefore, I decided to combine two files together and observe how it works. But, I change the value to $_POST[Name] and $_POST[Message] because the message needs to be stored randomly. Besides, I also add in echo '1 record added' to make sure the data is really connected.
After that, I try to write the code and submit.
But, it seems that the message still cannot be submitted. And the column of the message keep appear blank.
Therefore, I decided to ask question at Stackoverflow.
Above is the answer that I get from different people. The problem is coming from the "FORM" because I don't close the "FORM" bracket. After I adjust the place of the "FORM", the data can be inserted.
And the data is inserted successfully! :)
Reference:
YouTube. (2017). How to insert data into MySQL Database using PHP. [online] Available at: https://www.youtube.com/watch?v=-DD7eVeFWiE [Accessed 1 Jan. 2017].
People.cs.ksu.edu. (2017). An example to insert some data in to the MySQL database using PHP. [online] Available at: http://people.cs.ksu.edu/~hankley/d764/tut06/GopisettyPHP.html [Accessed 1 Jan. 2017].
method, I. (2017). Inserting datafrom form into mysql with POST method. [online] Stackoverflow.com. Available at: http://stackoverflow.com/questions/20305699/inserting-datafrom-form-into-mysql-with-post-method [Accessed 1 Jan. 2017].
YouTube. (2017). How to Create an HTML Form That Stores Data in a MySQL Database Using PHP Part 4 of 4. [online] Available at: https://www.youtube.com/watch?v=4HlgO7EY0J4 [Accessed 1 Jan. 2017].
Markle, B. (2017). Using PHP to INSERT data into a database - InMotion Hosting. [online] Inmotionhosting.com. Available at: http://www.inmotionhosting.com/support/edu/website-design/using-php-and-mysql/php-insert-database [Accessed 1 Jan. 2017].
PHP, M. (2017). My SQL data went blank when data is inserted in PHP. [online] Stackoverflow.com. Available at: http://stackoverflow.com/questions/41410828/my-sql-data-went-blank-when-data-is-inserted-in-php?noredirect=1#comment70025069_41410828 [Accessed 1 Jan. 2017].