Forum Moderators: coopster
The following is the code i'm using to test
$password=$_POST["password"];
$password = test($password);
$password= md5($password);
// basic injection check
function test($password)
{
$magic_quotes_active = get_magic_quotes_gpc() ;
$new_php_version = function_exists("mysql_real_escape_string") ; // php version >= 4.3.0
if($new_php_version){ // if new php version undo magic quotes
if($magic_quotes_active){ $password= stripslashes($password);}
$password= mysql_real_escape_string($password);
}
else { // version is older than 4.3.0
if(!$magic_quotes_active){$value=addslashes($value);} //check if magic quotes is not active then manually add slashes
}
return $password ;
}
// Here we check the the form password with the database one
checkpassword($password);
function checkpassword($password){
$query = ("SELECT `pass` , `station` FROM `check` ");
$answer = mysql_query($query) or die("Query Failed".mysql_error());
$result = mysql_fetch_array($answer);
if ( $result[0] != $password ){
echo ("Check Password"."<br/>");
} else{
echo("All OK"."<br/>");
}
// Next we just print them out to check visually
echo ( "PASSWORD = " .$password ."<br/>". "result = ".$result[0]."<br/>". "station = ".$result[1]."<br/>") ;
}
..and Welcome to WebmasterWorld!