POST input_filter() in PHP

Today I am going to show the details about the input_filter() function in PHP for POST method. In this case, we have to create 2 files entitled form.php and form_process.php files. So, let’s start the work-


echo showIt();
function showIt(){
$r = ”;
$r .= ‘<form method=”POST” action=”inputFilter.php”>’;
$r .= ‘<table>’;
$r .= ‘<tr><td>ID :</td><td><input type=”text” name=”id2″/> (must be between 3 and 10)</td></tr>’;
$r .= ‘<tr><td></td><td><input type=”submit” name=”submit” value=”POST”/></td></tr>’;
$r .= ‘</table>’;
$r .= ‘</form>’;
return $r;

Now, I am going to write the code for form_process.php file. The code is below-

$id = filter_input(INPUT_POST, ‘id’, FILTER_VALIDATE_INT, array(‘options’=>array(‘min_range’=>3, ‘max_range’=>10)));
       echo “The ID arguments is missing”;
}elseif($id === false){
       echo “The ID argument must be an integar between 3 and 10”;
       echo “ID is valid : $id”;


Ok, now run the file of form.php and write the code. Hope it’s ok now. Everything is going well. Isn’t it? Sound good.

Thanks for reading. Bye.


Leave a Reply

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

You are commenting using your 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