By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,929 Members | 631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,929 IT Pros & Developers. It's quick & easy.

Odd problem: Data from hidden field is not sent to server...

P: n/a

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

Jul 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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


One last point - If I manually write data in to the input tag field
named mylist, and post, then that value does get sent to the server -
however if javascript gives mylist a value, then it does not get sent to
the server.

Does anyone have any ideas?

randelld
Jul 17 '05 #2

P: n/a
"Randell D." <re******************************@fiprojects.moc > wrote in
message news:lC_Nd.321423$8l.315942@pd7tw1no...
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.
<snipped/> 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


One last point - If I manually write data in to the input tag field
named mylist, and post, then that value does get sent to the server -
however if javascript gives mylist a value, then it does not get sent to
the server.


Then we must see the actual javascript code that gives mylist a value.

--
Dag.
Jul 17 '05 #3

P: n/a

Randell D. wrote:
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

One last point - If I manually write data in to the input tag field
named mylist, and post, then that value does get sent to the server -

however if javascript gives mylist a value, then it does not get sent to the server.

Does anyone have any ideas?

randelld

would be good to see the code...

and: what kind of value do you assign to your hidden field?

micha

Jul 17 '05 #4

P: n/a
Randell D. wrote:
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


One last point - If I manually write data in to the input tag field
named mylist, and post, then that value does get sent to the server -
however if javascript gives mylist a value, then it does not get sent to
the server.

Does anyone have any ideas?

randelld

Dag / Micha,

I've copied the code to

http://www.fiprojects.co.uk/myproblem.txt

The application is for an intranet and thus not visable to the
internet... Let us know if you can put any light on it...

Thanks...
Randell D.
Jul 17 '05 #5

P: n/a
I noticed that Message-ID: <Nu_Nd.322273$6l.46322@pd7tw2no> from Randell
D. contained the following:
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...


Well, as you might expect in a PHP group, my idea would be to dump
JavaScript and get PHP to write the hidden fields.
I did something similar for lesson 5 of my PHP course
See http://www.ckdog.co.uk/phpcourse/Names2.php and for the code
http://www.ckdog.co.uk/phpcourse/Names2.phps
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID: <Nu_Nd.322273$6l.46322@pd7tw2no> from Randell
D. contained the following:

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...

Well, as you might expect in a PHP group, my idea would be to dump
JavaScript and get PHP to write the hidden fields.
I did something similar for lesson 5 of my PHP course
See http://www.ckdog.co.uk/phpcourse/Names2.php and for the code
http://www.ckdog.co.uk/phpcourse/Names2.phps


No - You have done something different - My approach means I do not know
the names - The end user enters the names from the client - Instead of
them posting several names to the server, I wanted to store the names
ina hidden box - then when they are finished,they could submit the form
posting the list of names in a hidden box to the server (thus, a single
post for what could be five, ten or twenty names). I made my hidden box
a normal input type=text box and could see my javascript was writing the
names into the box just fine however when I would post the form,
$_POST would have the input field name, but no value.

I think I'll create a quick page and put it up on the net as my ISP
gives me PHP on a Linux box - If the problem fails to repeat itself
there, then it sounds like its a windoze/php based server problem (I
develope on a windoze xp platform but will deliver my code to a linux box).

thanks for the suggestion though...
randelld
Jul 17 '05 #7

P: n/a
Randell D. wrote:
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


One last point - If I manually write data in to the input tag field
named mylist, and post, then that value does get sent to the server -
however if javascript gives mylist a value, then it does not get sent to
the server.

Does anyone have any ideas?

randelld


Some progress...

I created a new dummy form to perform the same process, from scratch
except I'm using the original javascript function - untouched.

For some reason, the code works for me... so I gather my javascript
function is fine but somehow, my html code has a bad tag or something in
it...

I will work on it a little more... thanks though
randelld

Jul 17 '05 #8

P: n/a
I noticed that Message-ID: <K68Od.329911$6l.102894@pd7tw2no> from
Randell D. contained the following:
No - You have done something different - My approach means I do not know
the names - The end user enters the names from the client - Instead of
them posting several names to the server, I wanted to store the names
ina hidden box - then when they are finished,they could submit the form
posting the list of names in a hidden box to the server (thus, a single
post for what could be five, ten or twenty names).


Well it could easily be adapted.

I'd normally frown on an exclusively Javascript solution but as it's an
intranet you have control over that. Equally, as it's an intranet,
multiple server calls are no major problem either.

If you go the Jave Script route, though it's possible someone else knows
the solution, you'd obviously be better off asking in a JS group

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #9

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID: <K68Od.329911$6l.102894@pd7tw2no> from
Randell D. contained the following:

No - You have done something different - My approach means I do not know
the names - The end user enters the names from the client - Instead of
them posting several names to the server, I wanted to store the names
ina hidden box - then when they are finished,they could submit the form
posting the list of names in a hidden box to the server (thus, a single
post for what could be five, ten or twenty names).

Well it could easily be adapted.

I'd normally frown on an exclusively Javascript solution but as it's an
intranet you have control over that. Equally, as it's an intranet,
multiple server calls are no major problem either.

If you go the Jave Script route, though it's possible someone else knows
the solution, you'd obviously be better off asking in a JS group


Thanks Geoff... but... I errrummaaaa... had copied both comp.lang.php
and comp.lang.javascript into my OP to ensure I covered my bases

thanks
randelld
Jul 17 '05 #10

P: n/a
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
Jul 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.