Displaying flag value in form ...
| From: | Miles Thompson | Date: | Wed, 06 Dec 2000 20:49:06 +0000 |
| Subject: | Displaying flag value in form ... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28984@lists.php.net to get a copy of this message | ||
I took a leaf (page?) from Julie Meloni's web site and used one of her
structures for a user registration form. The form is assigned to a
variable, issuing echo $user_form; display's it. I'm wanting to validate
certain fields and flag them with a bold, red asterisk. A separate
function, ChkEmptyFields() is used for field checking.
The checking routine works allright, and the form redisplays, etc., but
I haven't been able to display the asterisk.
This is for a multi-lingual market, so the form prompts are fetched from
a database and stored in the associative array arr_lbl[ ], which you'll
see in the following code fragment for definition of the form:
$user_form = "
<form method=\"post\" action=\"$PHP_SELF\">
<P>" . $arr_lbl[ lbl_cUsername ] . "
<input type=\"text\" name=\"cUsername\"
value=\"$cUsername\" $cDisabled size=10 > $cFlgUsername </p>
<P>" . $arr_lbl[ lbl_cEmail ] . "
<input type=\"text\" name=\"cEmail\"
value=\"$cEmail\" size=50 maxlength=50>$cFlgEmail</p>
... other fields ... buttons to do things ... </form>";
If $cUsername is empty, then the function ChkEmptyFields() set's
$cFlgUsername as follows:
$cFlagFld = "<font color=\"red\"
size=\"+4\"><bold>*</bold></font>";
$cChkOK = "yes";
function ChkEmptyFields()
{
global $cFlagFld, $cFlgUsername, $cChkOK, $cUsername. ... and others
...;
if( empty( $cUsername ) ) { $cFlgUsername = $cFlagFld; $cChkOK =
'no'; }
... and check other fields ...
}
I do not believe it's a scoping problem, I'm able to display the values
of $cUserName, $cChkOK and $cFlgUsername both within the function and
outside it using an echo statements.
My problem is getting $cFlgUsername to display within the form. I have
tried
1. ...$cDisabled size=10 >" . $cFlgUsername ." </p> - no error
messages, but no display of value.
2. ...$cDisabled size=10 >" . <? echo $cFlgUsername ?> ." </p>
3. ...$cDisabled size=10 >" . echo "$cFlgUsername"; . " </p>
4. ...$cDisabled size=10 > \"$cFlgUsername\" </p>
Numbers 2. and 3. wouldn't parse and threw error messages.
Number 4. prints the prompt, the text box and two quotation marks.
This has to be something simple, and I'm missing it. Suggestions will be
welcome.
Yours truly - Miles Thompson