In the php Tutorial, trim () form verification is not a null instance. It should be an entry-level instance. It tells you how to use the trim function to delete spaces and determine whether the data submitted by the user is empty.
<Html>
<Body>
<Form method = "post" action = "formerrorcheck. php">
<H1> contact information <Table>
<Tr>
<Td> <B> nickname: </B> </td>
<Td> <input type = "text" name = "nickname"> </td>
</Tr>
<Tr>
<Td> title: </td>
<Td> <input type = "text" name = "title"> </td>
</Tr>
<Tr>
<Td> <B> first name: </B> </td>
<Td> <input type = "text" name = "firstname"> </td>
</Tr>
<Tr>
<Td> middle name: </td>
<Td> <input type = "text" name = "middlename"> </td>
</Tr>
<Tr>
<Td> <B> last name: </B> </td>
<Td> <input type = "text" name = "lastname"> </td>
</Tr>
<Tr>
<Td> <B> primary email: </B> </td>
<Td> <input type = "text" name = "email"> </td>
<Td width = "20"> & nbsp; </td>
<Td> secondary email: </td>
<Td> <input type = "text" name = "secondaryemail"> </td>
</Tr>
<Tr>
<Td> company name: </td>
<Td> <input type = "text" name = "companyname"> </td>
</Tr>
<Tr>
<Td> office address: </td>
<Td> <input type = "text" name = "officeaddres1"> </td>
<Td width = "20"> & nbsp; </td>
<Td> home address: </td>
<Td> <input type = "text" name = "homeaddress"> </td>
</Tr>
<Tr>
<Td> </td>
<Td> <input type = "text" name = "officeaddress2"> </td>
</Tr>
<Tr>
<Td> city: </td>
<Td> <input type = "text" name = "officecity"> </td>
<Td width = "20"> & nbsp; </td>
<Td> & nbsp; </td>
<Td> <input type = "text" name = "homecity"> </td>
</Tr>
<Tr>
<Td> state: </td>
<Td> <input type = "text" name = "officestate"> </td>
<Td width = "20"> & nbsp; </td>
<Td> & nbsp; </td>
<Td> <input type = "text" name = "homestate"> </td>
</Tr>
<Tr>
<Td> zip: </td>
<Td> <input type = "text" name = "officezip"> </td>
<Td width = "20"> & nbsp; </td>
<Td> & nbsp; </td>
<Td> <input type = "text" name = "homezip"> </td>
</Tr>
<Tr>
<Td> phone: </td>
<Td> <input type = "text" name = "officephone"> </td>
<Td width = "20"> & nbsp; </td>
<Td> & nbsp; </td>
<Td> <input type = "text" name = "homephone"> </td>
</Tr>
<Tr>
<Td> birthday: </td>
<Td> <input type = "text" name = "birthday"> </td>
</Tr>
<Tr>
<Td> spouse name: </td>
<Td> <input type = "text" name = "spousename"> </td>
<Td width = "20"> & nbsp; </td>
<Td> childrens 'names: </td>
<Td> <input type = "text" name = "children"> </td>
</Tr>
<Tr>
<Td> anniversary: </td>
<Td> <input type = "text" name = "anniversary"> </td>
</Tr>
</Table>
<Br>
<Br>
<Br>
<Input type = "submit" value = "submit">
<Br>
<Br>
<Input type = "reset" value = "clear the form">
</Form>
</Body>
</Html>
<! -- Formerrorcheck. php
<Html>
<Body>
<? Php
$ Errors = 0;
If (! Trim ($ nickname )){
Echo "<br> <B> nickname </B> is required .";
$ Errors ++;
}
If (! Trim ($ firstname )){
Echo "<br> <B> first name </B> is required .";
$ Errors ++;
}
If (! Trim ($ lastname )){
Echo "<br> <B> last name </B> is required .";
$ Errors ++;
}
If (! Trim ($ email )){
Echo "<br> <B> primary email address </B> is required .";
$ Errors ++;
}
If ($ errors> 0)
Echo "<br> please use your browser's back button ".
"To return to the form, and correct error (s )";
?>
</Body>
</Html>