This is a discussion on Odd problem: Data from hidden field is not sent to server... within the PHP Language forums, part of the PHP Programming Forums category; Randell D. wrote: > > Folks, > > Perhaps someone can figure this out - this is 'the process of my ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Randell D. wrote:
> > Folks, > > Perhaps someone can figure this out - this is 'the process of my script' > > I have a form whereby I can add multiple contacts to a single address. > There is only one firstname/lastname/telephone box - when the user > clicks the add button, I read the values from the form fields and > record them into a hidden text input field. This part works because > during debugging, I have converted the <input type=hidden> into a <input > type=text> to visably confirm my data is being copied into the 'hidden' > field. > > Once the user has entered in one or more names, they can click another > button and submit the form for processing. My idea is that I would then > parse this hidden field server side... > > I have a WAMPHP based server and as a test, I dump out my entire $_POST > (basically, the name and value in every INPUT tag). > > My PHP script picks up the name of every input tag, including the hidden > field (like it should) but for some reason, the value that was written > to the hidden field is not passed to the server. Thus, for the PHP folk > reading this post, my hidden input field is called mylist and > $_POST['mylist'] exists, but its empty. Even though before processing, > I could visably see the input in the box (for debugging remember, I made > the input tag box a normal, unhidden one). > > Here is what I have done to try and resolve: > - I have used both Mozilla 1.7.5 and IE6 - both provide same results - > my hidden field name gets passed, but not its value. > > - I have created another hidden field and given it a default value ie I > have <input type="hidden" name="extraone" value="xyz"> and I get > $_POST['extraone']="xyz" passed to my php server, like I would expect - > however, the value of mylist is sent empty, even though it has data. > > - I have even put in a javascript alert box just before the form is sent > to the server and can see the result in my (unhidden) box, and the same > value displayed in the javascript alert - but again, the value of the > mylist does not get sent to the server. > > > The only difference is that my hidden field (even if its displayed like > an ordinary text input box) does not post data written to form fields as > the result of a javascript function. Interestingly though, the server > does know about the input tag box since it does receive > $_POST['mylist'], it justs receives it empty. > > What gives? If the form reads my input from one field, and writes it to > another field, then it should be sent to the server, true? > > Also... my tags are all inside my <form></form> tag (which is proven by > double checking, and the fact that I do get the input tag box name sent > to my server). > > Since I can see the data values in the box, it tells me my javascript is > doing what it should be doing - so I don't see any point in including my > javascript (though I have no problems doing so if someone requests > it). On the php server, I am using a simple phpinfo(); to check the > data is being received... > > Has anybody got any ideas on this one? I'm tired racking my brains on > this one - I just might go to bed and try a fresh approach after a few > hours sleep... > > Thanks in advance, > Randell D > Sorted it! It was a self induced PHP problem! I have a function that sanitizes my form data - Part of the function includes the escaping of special characters while another part ensures no one input tag field is longer than 50characters in length... because mylist was, it was being cleared... Silly of me really... but glad for the help from everyone anyway... randelld |