problem with php + form + input type = "hidden"

problem with php + form + input type = "hidden"

am 17.10.2007 03:19:43 von DBA

Without giving a lot of script at this time, I am having a problem with
php and form input type="hidden". Problem is that the hidden variable
displays last line from database query.

Some code.
if ($field_name=="member_lname") {
echo " " .
$result['member_lname'] . ', ' . $result['member_fname'] . "
";
echo "" . $result['member_id'] . " />" ; }

produces this from form:
Back, Joe 0026
Clan, Bill 0025
Dant, Norbert 0020
Cleene, Nor 0013
De Wa, Frank 0012
Erick, B.C. 0006
Evans, Mary 0027
Far, Steve 0005

after selection from form $_POST produces
correct name "Dant, Norbert" but grabs last number "0005" and not "0020".

Any help would be appreciated.

Re: problem with php + form + input type = "hidden"

am 17.10.2007 03:25:08 von unknown

Post removed (X-No-Archive: yes)

Re: problem with php + form + input type = "hidden"

am 17.10.2007 04:09:51 von DBA

My output is as follows:

************************************************************ *********************************
you entered display1.php

Array ( [cccb_id] => 00007 [selection] => 00008Executive Committee )

selection is: 00008Executive Committee
member_id is: cccb_id is: 00007

************************************************************ **********************************

Now, as you can see from the about output, the array cccb_id indicates
00007 while I also get 00008 which is correct. The 00007 is the last row
selected from the database. The name of the committee "Executive
Committee" is correct. So part of the data being returned is correct by
part is not. The part that is not is the 'input type="hidden" as
indicated in the initial thread.

Also, I appreciate critical remarks about my code but would like an
explanation. If I was sloppy enough to make the mistake I probably did
not know it was sloppy or why it was sloppy. Please elaborate.



Gary L. Burnore wrote:

> On Wed, 17 Oct 2007 01:19:43 GMT, dba wrote:
>
>
>>Without giving a lot of script at this time, I am having a problem with
>>php and form input type="hidden". Problem is that the hidden variable
>>displays last line from database query.
>>
>>Some code.
>>if ($field_name=="member_lname") {
>>echo " " .
>>$result['member_lname'] . ', ' . $result['member_fname'] . "
";
>
>
>
>>echo "" . $result['member_id'] . " />" ; }
>
>
> This would return:
>
> NNNNN />
>
> Bet that's not what you want.
>
> Oh, and ; } is sloppy programming.
>
>
>
>
>
>
>>produces this from form:
>>Back, Joe 0026
>>Clan, Bill 0025
>>Dant, Norbert 0020
>>Cleene, Nor 0013
>>De Wa, Frank 0012
>>Erick, B.C. 0006
>>Evans, Mary 0027
>>Far, Steve 0005
>>
>>after selection from form $_POST produces
>>correct name "Dant, Norbert" but grabs last number "0005" and not "0020".
>>
>>Any help would be appreciated.

Re: problem with php + form + input type = "hidden"

am 17.10.2007 04:24:41 von unknown

Post removed (X-No-Archive: yes)

Re: problem with php + form + input type = "hidden"

am 17.10.2007 13:59:20 von AnrDaemon

Greetings, dba.
In reply to Your message dated 17 ÏËÔÑÂÒÑ 2007 Ç., 05:19:43,

d> Without giving a lot of script at this time, I am having a problem with
d> php and form input type="hidden". Problem is that the hidden variable
d> displays last line from database query.

d> Some code.
[snip]

d> produces this from form:
[snip]

d> after selection from form $_POST produces
d> correct name "Dant, Norbert" but grabs last number "0005" and not "0020".

First, to lower chance of messing with output, use templates.
Second... Don't forget to escape output.

That way, Your code may looks like this


if ($field_name=="member_lname")
{
$_name = htmlspecialchars($result['member_lname'] . ', ' . $result['member_fname']);
$_id = $result['member_id'];
echo "$_name
";
echo "";
}

?>

Good luck with this code :)

P.S.
Aside from that, I think You would be better with
echo "$_name
";


--
Sincerely Yours, AnrDaemon

Re: problem with php + form + input type = "hidden"

am 17.10.2007 15:24:24 von DBA

AnrDaemon,

Thanks for the suggestions. Have been planning on looking into templates
at some time in the future and will do so.



AnrDaemon wrote:

> Greetings, dba.
> In reply to Your message dated 17 ÏËÔÑÂÒÑ 2007 Ç., 05:19:43,
>
> d> Without giving a lot of script at this time, I am having a problem with
> d> php and form input type="hidden". Problem is that the hidden variable
> d> displays last line from database query.
>
> d> Some code.
> [snip]
>
> d> produces this from form:
> [snip]
>
> d> after selection from form $_POST produces
> d> correct name "Dant, Norbert" but grabs last number "0005" and not "0020".
>
> First, to lower chance of messing with output, use templates.
> Second... Don't forget to escape output.
>
> That way, Your code may looks like this
>
> >
> if ($field_name=="member_lname")
> {
> $_name = htmlspecialchars($result['member_lname'] . ', ' . $result['member_fname']);
> $_id = $result['member_id'];
> echo "$_name
";
> echo "";
> }
>
> ?>
>
> Good luck with this code :)
>
> P.S.
> Aside from that, I think You would be better with
> echo "$_name
";
>
>