Click to See Complete Forum and Search --> : Input field - Echo post only from ID, not name
Siddan
01-22-2008, 04:43 PM
Here is something really difficult to search for. So I hope someone experienced may hand me a nice reply :)
Short story:
I have a mailform where I have no control over the input fields, so I cannot determine the NAME of the input field as it is automatically generated. But.... I can add a custom code like id=namefield" for instance.
Now the question:
It seems like I cannot retrieve any information from the field by its ID, only from the NAME. Does it make any sense?
Is there a way somehow to retrieve any information from the ID at all?
This would really lift a huge burden off me
/thanks
Siddan
01-31-2008, 06:24 AM
I didnīt expect this question would be so difficult for many :)
GavinPearce
01-31-2008, 06:45 AM
Hey Siddan,
Why can't you just collect the value from the name, why the need to specify an ID? Might be able to help us answer your question in more detail.
When you submit a form, the browser controls what information gets sent off, for example Firefox sends off the following under POST.
POST /n/ HTTP/1.1
Host: www.gavinpearce.co.uk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.example.net/
Content-Type: application/x-www-form-urlencoded
Content-Length: 40
username=test&password=test&submit=Login
HTTP/1.x 200 OK
Date: Thu, 31 Jan 2008 12:45:23 GMT
Server: Apache/1.3.39 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.30 OpenSSL/0.9.7a
Set-Cookie: PHPSESSID=4d2fc75bf45345345467a9dd1bd8d30; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/xhtml+xml;charset=UTF-8
----------------------------------------------------------
The important bit being:
username=test&password=test&submit=Login
I can't see a way around getting the browser to submit an ID tag along with the name tag to the server in PHP, however if you have the ability to add JavaScript to the page then you might be able to do some magic with that to make it modify the name field to match the ID field before posting to the browser.
If that makes sense.
jasonahoule
01-31-2008, 12:49 PM
If you don't know the names then just loop through the $_REQUEST array and get the values that way.
GavinPearce
02-01-2008, 03:52 AM
What are you trying to achieve, we might be able to help more then?
If the problem is you don't know the names, then jasonhoule's idea is your pretty sound bet.