note 108859 added to language.functions
| From: | roney458 at hotmail dot com | Date: | Wed, 30 May 2012 21:40:47 +0000 |
| Subject: | note 108859 added to language.functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188306@lists.php.net to get a copy of this message | ||
sample validation for internal php functions including $errMsg and if statements.
<?php
$errMsg = '';
$crsReq = 'You must select 1 option';
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']) <= 3)
$errMsg .= '(Q1) Please enter 4-6 digits for Student ID<br />';
if(strlen($_POST['studID']) >=7)
$errMsg .= '(Q1) Please enter 4-6 digits for Student ID<br />';
if(!isset($_POST['fullName']) || $_POST['fullName'] == '')
$errMsg .= '(Q1) Please enter your Name<br />';
if (!isset($_POST['crsReq'])) {
$errMsg .= 'Please select yes or no<br />';
$crsReq = '';
}
else {
$crsReq = $_POST['crsReq'];
}
if(!isset($_POST['crsNum']) || $_POST['crsNum'] == '')
$errMsg .= '(Q2) Please enter your course Number<br />';
if($_POST['ceremony'] != 'Spring' && $_POST['ceremony'] !=
'Autumn')
$errMsg .= '(Q4) Please indicate which graduation ceremony you want to attend<br
/>';
if($errMsg != '')
echo $errMsg;
else
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: 69.147.83.197
Probable Submitter: 122.106.54.18
----
Manual Page -- http://www.php.net/manual/en/language.functions.php
Edit -- https://master.php.net/note/edit/108859
Del: integrated -- https://master.php.net/note/delete/108859/integrated
Del: useless -- https://master.php.net/note/delete/108859/useless
Del: bad code -- https://master.php.net/note/delete/108859/bad+code
Del: spam -- https://master.php.net/note/delete/108859/spam
Del: non-english -- https://master.php.net/note/delete/108859/non-english
Del: in docs -- https://master.php.net/note/delete/108859/in+docs
Del: other reasons-- https://master.php.net/note/delete/108859
Reject -- https://master.php.net/note/reject/108859
Search -- https://master.php.net/manage/user-notes.php