Skip to content

Instantly share code, notes, and snippets.

@JZersche
Last active July 27, 2017 09:24
Show Gist options
  • Save JZersche/bc1ecbc9a55a6d8cdf2dab943bd5122c to your computer and use it in GitHub Desktop.
Save JZersche/bc1ecbc9a55a6d8cdf2dab943bd5122c to your computer and use it in GitHub Desktop.
Converts a string to an MD5 Hash
<!DOCTYPE html>
<html>
<head>
<style>
.error {color: #ff0000;}
</style>
</head>
<body>
<?php
$nameErr = '';
$name = '';
if ($_SERVER["REQUEST_METHOD"] == 'POST')
{
if (empty($_POST['name']))
{
$nameErr = ' DATA is required! ';
}
else {
$name = test_input($_POST["name"]);if (!preg_match("/^[a-zA-Z0-9]*$/",$name)) {$nameErr = " Only letters and white space allowed";}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<?php echo '<h2>MD5 Hasher Generator:</h2>';?>
<form method="post">
<input type="text" name="name" value="<?php echo $name;?>">
<input type="submit" name="submit" value="Convert">
<span style="color: blue; font-family: 'Segoe UI'; font-weight: Lighter; font-size: 1.2em;">
<?php echo $nameErr; echo md5($name);?>
</span>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment