Answers for "santinize user input and php"

PHP
2

how to request user input in php

<?php
echo "What do you want to input? ";
$input = rtrim(fgets(STDIN));
echo "I got it:\n" . $input;
Posted by: Guest on August-13-2020
1

sanitize user input php

<?php
function sanitize($stringToSanitize) {
	return addslashes(htmlspecialchars($stringToSanitize));
}
// You can just use the codes themselves instead of creating a function as:
echo addslashes(htmlspecialchars($stringToSanitize));
?>
Posted by: Guest on December-02-2020
0

php clean user input

<?php
    function cleanUserInput($userinput) {
  
  		// Open your database connection
      	$dbConnection = databaseConnect();
  
  		// check if input is empty
        if (empty($userinput)) {
          return;
        } else {
          
        // Strip any html characters
        $userinput = htmlspecialchars($userinput);
        
		// Clean input using the database  
        $userinput = mysqli_real_escape_string($dbConnection, $userinput);
        }
       
  	  // Return a cleaned string
      return $userinput;
    }
?>
Posted by: Guest on April-14-2020

Browse Popular Code Answers by Language