Overall · Technical

Speeding up the progress! (Submit user’s message into database)

Notes 25/12/2016
==============

HIGHLIGHT

I HAVE SUCCEEDED IN SUBMITTING MY MESSAGE INTO THE DATABASE, HURRAY!

All these moments I knew that there was something missing to connect these files together and I do not believe others’ method and due to my lazy symptoms and I did not try any of that. This might sound dramatic…? But at the end something clicked and I decided to just give it a try with others’ method and VIOLA.

1.png2.jpg3.jpg

http://www.phpsuperblog.com/php/insert-multiple-lines-from-textarea-of-html-form-into-mysql-database-with-php/
I followed and copied the code and paste it with mine and it WORKED *cries happy tears*… especially this $area = $_POST[‘area’]; As I have tried defining the input submit’s name and nothing happened but when I define the textarea’s name into a function it worked!

Backtrack to my previous attempts:

As my mindset was having 2 PHP files.

1.1 PHP file is to submit the messages to the database

1.2 PHP file is to form a connection to the database (MySQL)

From here, I missed out the point and all the research that I have found, I’ve noticed that they have included the database login details in each PHP files as they need to submit the data into the database as well as calling out the data from the database, and without it, nothing works.
So it does not send any data if I have 2 separate PHP files, thereforeĀ current update only used one PHP files that contain all the info inside and not separating it into another PHP files (I think I can separate it just that not sure if it looks tedious and it is still workable by including the “include “php file”, and ONE IMPORTANT THING WAS, that PHP file contained all my database login info which was risky and insecure and that’s why I think Mervin suggested me for having two files, however for current progress my final call will be using only one PHP. *Will further ask Mervin questions about this.

Furthermore, I have changed mysql to mysqli because of the system is deprecating so using mysqli and especially when I worked on the code secure system and read that the function mysql_real_escape_string is deprecating so I thought a little bit and might as well changed it.

Thoughts
Other than that, I think I confused myself with Mervin has suggested me about having 2 PHP files or not… I don’t recall, but that’s what I remembered vividly and he did drew out the process on his notebook.

References list

http://stackoverflow.com/questions/15331477/send-html-form-data-to-sql-database-via-php-using-mysqli

https://coolestguidesontheplanet.com/how-to-connect-to-a-mysql-database-with-php/

http://php.net/manual/en/book.mysqli.php
http://www.w3schools.com/php/php_mysql_insert.asp
http://php.net/mysql_real_escape_string
http://php.net/manual/en/mysqlinfo.api.choosing.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s