php function doesnt seem to be working.....
Question Details:I am trying to validate php form data, ideally I want to ensure that the text field has no whitespaces, and has a min AND max range.
Code:
<?php
require ('config.php');
$username=$_POST['usernam...
$offence=$_POST['offence'...
$punishment= $_POST['punishment'];
$database=naughtylist;
$table=naughty;
$min=1;
$max=15;
function checkLength($username, $min, $max) {
$length = strlen ($username);
if (($length < $min) || ($length > $max)) {
return FALSE;
} else {
return TRUE;
}
}
That code doesnt work....even when I leave the field blank, I do not get any errors/feedback etc.
If anyone can help me with regex in php generally or suggest a more efficient method of doing this then thanks.
Ive made a validation script in javascript, but I am wanting the php validation for an extra layer of protection.