Last active
July 27, 2017 09:23
-
-
Save JZersche/544a192d45120205e0e0602a6bee10d4 to your computer and use it in GitHub Desktop.
Converts entered text and letters in to a new custom format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.error {color: #ff0000;} | |
</style> | |
</head> | |
<body> | |
<form method="post"> | |
<input type="text" name="text" value="<?php $text?>"> | |
<input type="submit" name="submit" value="Convert"> | |
</form> | |
</body> | |
</html> | |
<?php | |
$nameErr = ''; | |
$text = ''; | |
if ($_SERVER["REQUEST_METHOD"] == 'POST') | |
{ | |
if (empty($_POST['text'])) | |
{ | |
$nameErr = ' DATA is required! '; | |
} | |
else { | |
$text = convert($_POST["text"]);if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $_POST["text"])) {echo $nameErr = "Only letters and white space allowed";} | |
} | |
} | |
function convert($text) { | |
if (strpos('B', $_POST["text"])!==true && strpos('C', $_POST["text"])!==true && !preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $_POST["text"])) { | |
$search = array('A','B','C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); | |
$convert = array('a','b','c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); | |
$text = str_replace($search, $convert, $_POST["text"]); | |
echo $text;} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment