PHP Classes

PHP Select Box Validation: Validate an option of a select input with its HTML

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 208 All time: 8,359 This week: 423Up
Version License PHP version Categories
selectbox-validator 1.0.0The PHP License5HTML, PHP 5, Validation, Parsers


This class can validate an option of a select input with its HTML.

It can take the HTML used to display a form select input and parses it to check if a given option makes part of the defined options.

The class can also extract the list of all available options and return an array with all the option values.

Innovation Award
PHP Programming Innovation award nominee
January 2019
Number 9
All the applications that generate HTML for the forms they present to their users know what are the valid options that the users may pick for select inputs.

However, when the applications use HTML for select input provided from other sources, the list of valid options depends on other applications that generated the HTML for the form.

This class provides a solution for validating forms with select inputs that are displayed using HTML provided by third-party applications that consist in parsing the HTML of the form select input to extract the list of valid options.

Manuel Lemos
Picture of peyman
  Performance   Level  
Name: peyman <contact>
Classes: 4 packages by
Country: Iran Iran
Age: ???
All time rank: 286450 in Iran Iran
Week rank: 411 Up5 in Iran Iran Up
Innovation award
Innovation award
Nominee: 4x



simple select box validator using select box html

what is this ?

when you are using a long select box in your website for example country selectbox or city selectbox or any other static selectbox user can simple edit the value of a option and send it to the backend and create alot of problem . users can attack your website using this method. to fix this problem you need to check if user sended the value from the selectbox itself or not if you are creating the selectbox from database then you can check the values there but if you are not, you need to convert all of the values from selectbox to array and then check them with user input this class does this both for you , you just need to simply copy the selectbox html

how to use?

setup :

$check = new selectbox_validator();

check :

check user input with values in select box using select box html

  • selectboxhtml : select box html for example :
      <option value="IR">Iran</option>
  • userinput : user input to check

return : true if found , false if not found

convert :

simple convert select box values to array

  • selectboxhtml : select box html for example :
      <option value="IR">Iran</option>

return : selext box values in array form that you can copy into php

  Files folder image Files  
File Role Description
Accessible without login Plain text file demo.php Example Example script
Accessible without login Plain text file Doc. Documentation
Plain text file selectbox_validator.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,359
This week:423Up
User Comments (1)