need to convert field names into array for form submission
| From: | Bruce Gilbert | Date: | Fri, 12 Aug 2005 19:39:54 +0000 |
| Subject: | need to convert field names into array for form submission | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-220527@lists.php.net to get a copy of this message | ||
How would I organize this block in order to convert it into an array
for my form field names.
For instance if my field has:
<p>Home Phone Number:</p> <input maxlength="6" size="6"
name="area_code" id="area_code"
value="{$_POST['area_code']}">
<input maxlength="6" size="6"
name="phone_exchange" id="phone_exchange"
value="{$_POST['phone_exchange']}">
<input maxlength="10" size="10"
name="last_4_digits" id="last_4_digits"
value="{$_POST['last_4_digits']}">
I would want something to return an error stating that the phone
number was not completed and not that the field last_4_digits was not
entered.
I believe this can be done with an array.
my error block code is:
function check($fieldname)
{
global $err_msg;
if($_POST[$fieldname] == "") {
if ( !isset($err_msg)) {
$err_msg = "<div class='red'>You haven't entered
your " . str_replace("_", " ", $fieldname) . "!</div><br
/>";
} elseif ( isset($err_msg)) {
$err_msg .="<div class='red'>You haven't entered
your " . str_replace("_", " ", $fieldname) . "!</div><br
/>";
}
}
return $err_msg;
}
any assistance is greatly appreciated!
--
::Bruce::