string md5 ( string str [, bool raw_output] ) : md5 « Utility Function « PHP






string md5 ( string str [, bool raw_output] )

 
<?php
$GLOBALS ['username'] = "test";
$GLOBALS ['password'] = "test";

setcookie ( "cookie_user", "test", time () + 60 * 60 * 24 * 30 );
setcookie ( "cookie_pass", md5 ( "test" ), time () + 60 * 60 * 24 * 30 );

function validatelogin() {
  if (strcmp ( $_COOKIE ['cookie_user'], $GLOBALS ['username'] ) == 0. && 
  strcmp ( $_COOKIE ['cookie_pass'], md5 ( $GLOBALS ['password'] ) ) == 0) {
    return true;
  } else {
    return false;
  }
}
if (validatelogin ()) {
  echo "Successfully logged in.";
} else {
  echo "Sorry, invalid login.";
}
?>
  
  








Related examples in the same category

1.Checking for session hijacking
2.string md5 ( string str [, bool raw_output] ) produces a data checksum in exactly the same way as sha1( );
3.Creating an md5 signature
4.PHP's basic md5() function
5.The protect() MD5 Form Fingerprint Generator
6.md5.php
7.Insert a unique ID into a form