Home arrow PHP arrow Advanced PHP Form Input Validation to Check User Inputs

Advanced PHP Form Input Validation to Check User Inputs

PHP form input validation is what separates amateur and professional PHP developers. A professional PHP developer validates data for both security and correctness of the data entered. Keep reading to learn how to validate user input to your forms.

  1. Advanced PHP Form Input Validation to Check User Inputs
  2. Validating Email Addresses
  3. Validating Domains for Email Addresses
  4. Validating Alphanumeric, Numeric and Alphabetic Input
By: Codex-M
Rating: starstarstarstarstar / 15
June 01, 2009

print this article



Web form processing is one of the most important tasks any website can do to process customer-related information. PHP server side scripting offers a variety of solutions for accepting and processing data inputs from any web form.

However, a lot of website forms do not have input validation. "Input validation" is the process of double checking form data input to ensure they are the correct data the server needs to process. Without proper form input validation, the web server and database will process or store the wrong information.

A classic example concerns forms that ask for an email address. If you do not validate the input data, malicious users can enter other types of characters into the form to hack your MySQL database. Serious website security issues, such as MySQL injection and malware injection, result from improper form input validation.

In this article, we will aim to provide PHP solutions which will validate the most common fields used in  website development:

  • Validating alphanumeric input -- This type of input is commonly used for usernames and passwords. "Alphanumeric" means the variable can contain numbers and letters of the alphabet only.

  • Validating numeric input -- Often, web forms ask for numbers. These can be phone numbers or credit card numbers. Other important applications include asking for a birth date, numbers would be entered by the user for the day, month and year of birth. That's numerical data.

  • Validating names -- This kind of validation should check for letters of the alphabet only; user input should not contain numbers.

  • Validating email address -- The email address is most commonly asked for in a web form. It's particularly common for a log-in page.

  • Validating for empty fields -- Often, certain fields must be filled on an online form, and the user is not permitted to leave them blank. 

>>> More PHP Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: