Re: Displaying flag value in form ...
| From: | Richard Lynch | Date: | Thu, 07 Dec 2000 04:22:07 +0000 |
| Subject: | Re: Displaying flag value in form ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29053@lists.php.net to get a copy of this message | ||
If the form is also being printed by a function, you need:
global $cFlgUsername;
at the top of that function.
----- Original Message -----
From: Miles Thompson <milesthompson@sprint.ca>
Newsgroups: php.general
Sent: Wednesday, December 06, 2000 2:46 PM
Subject: [PHP] Displaying flag value in form ...
> 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
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>