Checking for magic quotes : htmlentities « HTML « PHP






Checking for magic quotes

 
<?php
if (is_null($_GET["search"])) {
    echo '<form method="'.htmlentities($_SERVER["PHP_SELF"]).'" method="GET">';
    echo '    <label>';
    echo '       Search:';
    echo '       <input type="text" name="search" id="search" />';
    echo '    </label>';
    echo '    <input type="submit" value="Go!" />';
    echo '</form>';
    } else {
    $search = $_GET["search"];

    if (!get_magic_quotes_gpc(  )) {
        $search = htmlentities($search);
    }
    if ($search != NULL ){
        echo "The search string is: <strong>$search</strong>.";
    }
}
?>
  
  








Related examples in the same category

1.Generating XML from an array
2.htmlentities() function converts all characters into their equivalent HTML entities.
3.htmlentities.php
4.Encoding HTML entities in a string
5.Escaping HTML