473,789 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 "<input type='radio' name='selection ' value=' " .
$result['member_lname']. ',' .$result['member_fname'] ." ' " .
$result['member_lname'] . ', ' . $result['member_fname'] . "<br />";
echo "<input type='hidden' name='member_id ' value=" .
$result['member_id'] . " ' >" . $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.
Oct 17 '07 #1
3 3508
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 <db*@somewhere. orgwrote:

>>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 "<input type='radio' name='selection ' value=' " .
$result['member_lname']. ',' .$result['member_fname'] ." ' " .
$result['member_lname'] . ', ' . $result['member_fname'] . "<br />";


>>echo "<input type='hidden' name='member_id ' value=" .
$result['member_id'] . " ' >" . $result['member_id'] . " />" ; }


This would return:

<input type='hidden' name='member_id ' value=NNNN ' 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.
Oct 17 '07 #2
Greetings, dba.
In reply to Your message dated 17 ÏËÔÑÂÒÑ 2007 Ç., 05:19:43,

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

dSome code.
[snip]

dproduces this from form:
[snip]

dafter selection from form $_POST produces
dcorrect 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

<?php

if ($field_name==" member_lname")
{
$_name = htmlspecialchar s($result['member_lname'] . ', ' . $result['member_fname']);
$_id = $result['member_id'];
echo "<input type='radio' name='selection ' value='{$_name} '/>$_name<br />";
echo "<input type='hidden' name='member_id ' value='{$_id}'/>";
}

?>

Good luck with this code :)

P.S.
Aside from that, I think You would be better with
echo "<input type='radio' name='selection ' value='{$_id}'/>$_name<br />";
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru>

Oct 17 '07 #3
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,

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

dSome code.
[snip]

dproduces this from form:
[snip]

dafter selection from form $_POST produces
dcorrect 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

<?php

if ($field_name==" member_lname")
{
$_name = htmlspecialchar s($result['member_lname'] . ', ' . $result['member_fname']);
$_id = $result['member_id'];
echo "<input type='radio' name='selection ' value='{$_name} '/>$_name<br />";
echo "<input type='hidden' name='member_id ' value='{$_id}'/>";
}

?>

Good luck with this code :)

P.S.
Aside from that, I think You would be better with
echo "<input type='radio' name='selection ' value='{$_id}'/>$_name<br />";

Oct 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2590
by: Stone | last post by:
OK .. admittedly this is newbie dumb... Its a JAVA script in a FORM I have passed (successfully) the referring URL into my form page on loading.... <script language="JavaScript"><!-- // THIS IS THE URL FROM THE REFERRERING PAGE! var originalURL = unescape(location.search.substring(1)); //alert(originalURL ); // this works!
6
4486
by: Saqib Ali | last post by:
I have created a slider using Javascript and html tables that generally works very well. As you move the "knob" to the right, a numeric value in an adjactent <INPUT type="text"> tag increases. As you move the knob to the left, the numeric value decreases... just as it should. It works very smooth and seamlessly. Very responsive to the mouse's movement. Now, I would like to make this INPUT tag have type="hidden". But when
3
2411
by: neverstill | last post by:
hi- I need to have an asp:TextBox that will allow me to set the type attribute to hidden. I can't seem to find a way to do this. Basically, I have a Wizard application that will show/hide different panels for each step. I need to track what step I'm on, so I though I would just add a simple little hidden input and increment it each time. Not so easy. the Visible property of the basic asp:TextBox sets whether or not the control is...
3
1828
by: Mike Labosh | last post by:
I'm a middle tier (dll / MTS / COM+ / Extensions) guy and I'm a bit rusty on the GUI part of ASP.NET I have a web form that a user uses to cycle through records in the DB to review unmatched items and assign / fix them. I need the WebForm to contain the identity key from the SQL Server table so the Save button can pass it in a WHERE clause so that the system updates the correct record, but I don't want the user to SEE this value on the...
2
5165
by: SAL | last post by:
I have the following line of code in my Page_Load Event of my ASP.net page: txtExplanationofChange.Attributes.Add ("style","overflow :hidden"); which allows me to can turn off the Scrollbar of my multiline textbox. I am still fairly new to developing in ASP.net and C#, and I'm not sure if there is a better way to disable the scrollbar. The code above turns off the scrollbar just fine, however the textbox does not remain in the location...
7
201553
by: parag1234567 | last post by:
Hi, I am dynamically generating a html file which will contain only <div> tags which contents are hidden from user( set by style="visibility:hidden") Now the next step is i am enabling some of these tags by setting style="visible" here the problem is, the hidden items also occupy the space on html form is there any other ways such that all the content should present on html form in hidden form and run time I can make visible some of them as...
1
7084
by: mark | last post by:
Forgive me if this seems like a stupid question but I need help... I'm trying to do a simple online form that emails me the results from a few fields. Here is the code: <form action="http://cm1web1/WebSurveyComponents/script/ processform.asp" method="post">
1
6457
by: msg2ajay | last post by:
hi, i am working on <div> i have to hide some part of the table. I am not able to hide that table part can anybady tell me where is the error. <html> <head> <script type="text/javascript"> function callme(){ document.getElementById("hid").style.visibility="visible"; }
4
22174
by: aashen | last post by:
I'm building a new site and using the Lightbox2 photo gallery(http://www.huddletogether.com/projects/lightbox2/). I have several images...each open up their own gallery. I was having a problem with my cells increasing in height when applying the galleries to the image source. A forum member from Lightbox suggested using <div style="display:hidden">.....which works well in Firefox 2 and Netscape 8, but not in IE6(not sure about IE7). I know many...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.