____  ___    _  _     _   _ _____     _______
 / ___|/ _ \  | || |   | | | |_ _\ \   / / ____|
| |  _| | | | | || |_  | |_| || | \ \ / /|  _|
| |_| | |_| | |__   _| |  _  || |  \ V / | |___
 \____|\___/     |_|   |_| |_|___|  \_/  |_____|

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

HOW TO VALIDATE FORM INPUTS BEFORE SUBMISSION USING PHP.

BY: @lfcsince2005 | CREATED: March 4, 2018, 10:32 a.m. | VOTES: 2 | PAYOUT: $5.39 | [ VOTE ]

what you would learn

Requirements

Tutorial Contents

You might have a form on your website and you want to make sure that users fill in the required information before submission
First you must have created a form page and it looks like this

[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1520157487/oqcdodnp7qprsyoovjtf.png]

output should look like this
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1520157531/grtif5kmms51vbbsqrnh.png]

Next you create a div class that contains the error message and style it to color red it looks like this
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1520157591/vv4beoxniugvvanesnkc.png]

Then you write the PHP code for validation, here we use pregmatch, test_input and strlen.
Note: we are putting our PHP code in the same page as our form then use the PHP_SELF super global
Create a data base and a table that collects the information from the form so let’s use database “test” and table “validate” take a look at the table

[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1520157759/bsfsvv7k73feazfyxxnb.png]

Now put your action attribute and use “($_SERVER["PHP_SELF"])” with method as “post” then call for the error message by putting this code “

TAGS: [ #howto ] [ #steemstem ] [ #utopian-io ] [ #programming ] [ #science ]

Replies

@postpromoter | March 4, 2018, 3:26 p.m. | Votes: 0 | [ VOTE ]

You got a 0.98% upvote from @postpromoter courtesy of @sammyutd!

Want to promote your posts too? Check out the Steem Bot Tracker website for more info. If you would like to support the development of @postpromoter and the bot tracker please vote for @yabapmatt for witness!

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>