Wednesday, September 8, 2010

PHP Validate Form

Making the form on the php impressed casual. But one time we faced a problem with the validation of that form, eg filling of data can not be empty. Here are some scripts that can be used to check the validation of a form, especially checking space which can become the things we missed.

To make it easier, can be made a separate file with the parent file. suppose check.inc and later called in the php file using the command required


function check_not_empty($s, $include_whitespace = false)
{
if ($include_whitespace) {
// make it so strings containing white space are treated as empty too
$s = trim($s);
}
return (isset($s) && strlen($s)); // var is set and not an empty string ''
}
?>

2 comments:

  1. When I first saw this Hub about the Facebook audience claim that's off by 17,000 times my first thought was that Yo2k Nge's audience should read this! http://hubpages.com/hub/Lies-Damned-Lies-Statistics-ComScores-Facebook-Audience-Claims-Are-Wrong-By-A-Factor-Of-17-000 According to ComScore, the average Facebook user is online half a second per day! Yeah, sure!

    ReplyDelete
  2. When I read this blog I thought Linux and Health's commenters should read it too! http://hubpages.com/hub/rent-a-laptop-rentals . I can't understand renting a laptop at all, you might as well buy it than pay what the rental companies are going to charge you even for a two week rental!

    ReplyDelete