How to store textarea value in database in PHP

As a PHP beginner, I know the pain of saving form values in database. But don’t worry in this tutorial I am going to to store textarea value in database.

This tutorial is for beginner you can easily learn and implement in your future web development projects.

Also Read: Insert data in Mysql using Php Form

Store textarea value in database in PHP

how to store textarea value in database in PHP

I will create only one input field and store in mysql database. This process involves following steps.

  • Create HTML form and set method attribute value as POST.
  • Apply some css to the form for better look.
  • When forms submit get textarea and trim extra spaces from it.
  • Save into the Mysql Database.
  • If textarea saves successfully then show success msg.

Create Database:

Create Database Table:

Database Connection:

HTML:

In the above form, action attribute has $_SERVER['PHP_SELF'] which means form will post on the same page. If you don’t want to use $_SERVER['PHP_SELF'] then leave action attribute blank.

CSS:

Also Read: User Registration in PHP

Success Message:

PHP Code on Form Submission:

All Code Together:

 

Posted in PHP

3 Replies to “How to store textarea value in database in PHP”

      1. it worked i have change the textarea form attribute to class=”form-control” but i do have another that ai really want your help on , how to take the data from the form store it in the database as excel sheet that when someone search for this form data it will open to him as excel ?

Leave a Reply

Your email address will not be published. Required fields are marked *