So I'm new to php and I'm trying to do a simple input filter on my html form with ctype_print($_POST["commentContent"])
but it is not recognising illegal input. But when I use ctype_print($testCase)
it is working. How can I do ctype_print()
on a $_POST
input value. What am I missing here?
My code: Html form:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Recipe Site</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<h3>Comments:</h3>
<form action="" method="POST">
<textarea rows="10" cols="30" name="commentContent"></textarea>
<br />
<input type="submit" value="Post!">
<br />
</form>
</body>
</html>
Here is the sample string i use in both $testcase and that i post to the form: "asdf \t"
Simple if php
$testCase = "asdf
\t";
if (ctype_print ( $_POST ["commentContent"] )) {
echo "Great succes for: " . $_POST ["commentContent"];
} else {
echo "DAMN, it dosent work: " . $_POST ["commentContent"];
}
echo "<br>";
if (ctype_alnum ( $testCase )) {
echo "ctype on testcase works : " . $testCase;
} else {
echo "ctype on testcase does not work : " . $testCase;
}