Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] $_POST is getting only the last field
#5

(03-11-2015, 07:46 PM)ciadmin Wrote: Did you notice that your 'message' field is the only one with a 'name' attribute?
PHP uses that for POST parameters, and not the 'id' attribute.
Add the 'name' attribute to your other fields and they should be accessible to your code.

I just wanted to add a note that this is part of the standard for HTML forms, so it happens in the browser before PHP gets involved. I think most of us, as web developers, run into this at some point (hopefully early) in our careers, regardless of what language we use on the server.

With the increased use of AJAX libraries to submit forms, I occasionally run into a library that builds a POST and uses ID values if the names aren't present, but I would generally recommend avoiding depending on behavior like that, as it just becomes confusing and/or difficult to troubleshoot down the road.
Reply


Messages In This Thread
RE: [SOLVED] $_POST is getting only the last field - by mwhitney - 03-12-2015, 09:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB