PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

PHP FILTER SECURITY EXAMPLES

Go down

PHP FILTER SECURITY EXAMPLES Empty PHP FILTER SECURITY EXAMPLES

Post by jamied_uk 10th May 2016, 17:48

Code:

<?php
// ?url=

if(isset($_GET['url'])) {

$url = preg_replace('#[^a-z0-9]#i', '', $_GET['url']);
}

?>

<?php
$url = "http://www.w3schools.com";

// Remove all illegal characters from a url
$url = filter_var($url, FILTER_SANITIZE_URL);

// Validate url
if (!filter_var($url, FILTER_VALIDATE_URL) === false) {
    echo("$url is a valid URL");
} else {
    echo("$url is not a valid URL");
}
?>



http://www.w3schools.com/php/php_filter.asp
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

PHP FILTER SECURITY EXAMPLES Empty Re: PHP FILTER SECURITY EXAMPLES

Post by jamied_uk 10th May 2016, 17:50

jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum