I am learning PHP and I am at this point learning how to validate forms and client inputs.
Clearly I have misspelled, written something not related to PHP or anything like that, because I get nothing but a white screen, but I just can't find out where the error is generated.
A weird thing is, that even though I have turned on error reporting and displaying of errors all I get is a so-called WSOD (White Screen of Death)
This is the PHP-code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
if (array_key_exists('_submit_check', $_POST)) {
if (validate_form()) {
process_form();
} else {
show_form();
}
} else {
show_form();
}
function process_form() {
print "Hello, " . $_POST['my_name'];
}
function show_form() {
print<<<HTML
<form method="POST" action="$_SERVER[PHP_SELF]">
Your name: <input type="text" name="my_name">
<br>
<input type="submit" value="Say HEEELLOOO!">
<input type="hidden" name="_submit_check" value="1">
</form>
HTML;
}
function validate_form() {
if (strlen($_POST['my_name'] < 3) {
return false;
} else {
return true;
}
}
?>
Please no "Why are you doing this server-side? Bla bla bla", it's just an "excercise"
If you can spot where I made the error, please let me know and if you can tell me why i get nothing but a white screen when I make a mistake please let me know too! :) Thanks