Return to Snippet

Revision: 1959
at November 30, 2006 02:11 by atinamedia


Initial Code
<?php
// SECURE STRINGS IN LOGIN ETC.
// By Eduardo de la Torre from www.atinamedia.com

function clean_string($string, $length){
	$string = substr($string, 0, $length);
	$string = strip_tags(trim($string));
	return $string;
}

// Example:
// If... Triying XSS

$foo = "<scrip>alert(\"ALARM!!\");</script>";

// The length is limit to 40 characters (for example)
echo clean_string($foo, 40);
?>

Initial URL


Initial Description
By Eduardo de la Torre.

Initial Title
Securing & Cleaning Strings in inputs like Login, etc.

Initial Tags
login, php

Initial Language
PHP