note 108824 added to function.strlen

From: Date: Mon, 28 May 2012 10:37:26 +0000
Subject: note 108824 added to function.strlen
Groups: php.notes 
Request: Send a blank email to php-notes+get-188262@lists.php.net to get a copy of this message
strlen is very useful for validation. <?php $errMsg = ''; // validate student id if(!isset($_POST['studID']) || $_POST['studID'] == '') $errMsg .= '(Q1) Please enter your student ID<br />'; if(!is_numeric($_POST['studID'])) $errMsg .= '(Q1) Please enter numbers only for Student ID<br />'; if(strlen($_POST['studID']) != 8) $errMsg .= '(Q1) Please enter 8 digits for Student ID<br />'; // validate student name if(!isset($_POST['fullName']) || $_POST['fullName'] == '') $errMsg .= '(Q1) Please enter your Name<br />'; // validate course number if(!isset($_POST['crsNum']) || $_POST['crsNum'] == '') $errMsg .= '(Q2) Please enter your course Number<br />'; // validate graduation if($_POST['ceremony'] != 'Spring' && $_POST['ceremony'] != 'Autumn') $errMsg .= '(Q4) Please indicate which graduation ceremony you want to attend<br />'; // if there is errors display error messages if($errMsg != '') echo $errMsg; else // else display message echo "Thank you for your application {$_POST['studID']}, {$_POST['fullName']}. Your application to graduate from {$_POST['crsNum']} at the {$_POST['ceremony']} ceremony will now be processed."; ?> ---- Server IP: 113.20.13.217 Probable Submitter: 122.108.33.226 ---- Manual Page -- http://www.php.net/manual/en/function.strlen.php Edit -- https://master.php.net/note/edit/108824 Del: integrated -- https://master.php.net/note/delete/108824/integrated Del: useless -- https://master.php.net/note/delete/108824/useless Del: bad code -- https://master.php.net/note/delete/108824/bad+code Del: spam -- https://master.php.net/note/delete/108824/spam Del: non-english -- https://master.php.net/note/delete/108824/non-english Del: in docs -- https://master.php.net/note/delete/108824/in+docs Del: other reasons-- https://master.php.net/note/delete/108824 Reject -- https://master.php.net/note/reject/108824 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188262) next »