Phptrim () 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. & lt; html & gt; & lt; body & gt;
Php 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.
-
-
-
-
-
Formerrorcheck. php
-
-
-
- $ Errors = 0;
- If (! Trim ($ nickname )){
- Echo"
NicknameIs required .";
- $ Errors ++;
- }
-
- If (! Trim ($ firstname )){
- Echo"
First nameIs required .";
- $ Errors ++;
- }
-
- If (! Trim ($ lastname )){
- Echo"
Last nameIs required .";
- $ Errors ++;
- }
-
- If (! Trim ($ email )){
- Echo"
Primary email addressIs required .";
- $ Errors ++;
- }
-
- If ($ errors> 0)
- Echo"
Please use your browser's back button ".
- "To return to the form, and correct error (s )";
-
- ?>
-
-
-
This is a simple verification function:
- Function phone_validate ($ data, $ desc ){
- $ Regex = "/^ ([2-9] [0-9] {2 }) [2-9] [0-9] {2}-[0-9] {4}/I ";
- If (preg_match ($ regex, $ data )! = 1 ){
- Return "the '$ desc' field isn' t valid! ";
- }
- Return true;
- }
- ?>