rendered paste body<?php if(!isset($_POST['submit'])) {?> <form method='post' action='<? echo $_SERVER['PHP_SELF']; ?>'> <fieldset> <legend> enter a first name </legend> <input type='text' name='chars' size='20' maxlength='10' /><br /> <input type='submit' name='submit' value='Process' /> <input type='reset' value='Reset' /> </fieldset> </form><? } else { if (!empty($_POST['chars'])) $chars = trim($_POST['chars']); else echo 'field cannot be empty <br />'; $regexp = (preg_match('/[^a-z]/i', $chars) || preg_match('/[0-9]/', $chars)); if (!$regexp) { if (strlen($chars) < 2) echo 'name must be of at least 2 letters'; else { $pieces = explode(' ', $chars); for ($i = 0; $i < count($pieces); $i++) echo ucwords($pieces[$i]); } } else echo 'invalid, try again.'; }?>