Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Filtering the external input data in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 124
    Comment on it

    Here we will learn about the filter functions that are used to validate and sanitize the data and make sure that data is in proper form and all the illegal characters are removed from the data.The filter function are:
    filter_has_var()
    filter_id()


    The filter_has_var() helps us to find the variable is of same input type as it was specified.We can check for any type of variable.

    Syntax: filter_has_var(type, variable)

    type can be as follows: INPUT_GET
    INPUT_POST
    INPUT_COOKIE
    INPUT_SERVER
    INPUT_ENV

    For Example:

    <?php
    if (!filter_has_var(INPUT_GET, "email")) {
        echo("No Email Exists");
    } else {
        echo("Email Exists");
    }
    ?> 
    

    filter_id() function returns the filter ID of the VALIDATE_IP / Stripped filter:

    For Example:

    <?php
    $echo(filter_id("validate_ip")); 
    $echo(filter_id("stripped"));
    ?>
    output: 275
    output:513 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: