I just wrote this validation script for my site using functions. I just learned how to use parameters which means I might have made some error that many first timers usually make when learning new stuff.
Here is the code...
Thanks!PHP Code:function validateInput($content, $inputlabelname, $inputidname, $max, $min, $style, $type, $extravalidation){
if(strlen($content)<$max && strlen($content)>$min){
echo '<label>' . $content . '</label>';
}
else
{
echo '<label>Retype your ' . $inputlabelname . ':</label>';
echo '<input type="' . $type . '" id="' . $inputidname . '" style="' . $style . '"/>';
}
}//End of function
if(isset($_POST['firstname'])){
$value = htmlspecialchars($_POST['firstname']);
validateInput($value,"First Name","firstname",30,2,"width: 75px\;","text",FALSE);
}
else
{
echo 'YOU FORGOT YOUR NAME! 2 points off...';
}
I forgot to set the name attribute in the input tags... Silly me!


Reply With Quote
Bookmarks