0

Can you get a forms submitted data even when the input element has no name?

For example:

I coded a form then submitted it and have it processed by php but the form input elements have no name.

<form action="process.php" method="post" >
<input type="text" name="" />
<input type="text" name="" />
<input type="text" name="" />
<input type="submit" value="SUBMIT" />
</form>

How do I manage to get the data from the form even if the input has no name?

fja3omega
  • 202
  • 5
  • 14
  • 1
    You can't. Well, I guess you could but the trouble isn't really worth it. You always need some way to retrieve the data! So technically you could use Javascript to select the form element and retrieve all the values from its child elements. Then use javascript to POST the data with names through Ajax, but it's just doing the same as adding names to the input elements, only taking the sceneric route to get there. – icecub Oct 20 '16 at 03:52
  • Thanks. I wanted a generic way to get all the data from a form without needing a name for the input tags. Questioned answered I guess. – fja3omega Oct 20 '16 at 03:58
  • 1
    @fja3omega Yea, kind of a bummer. You might be able to use Javascript to loop through all input/select/etc elements, put their values in an array, and then use Ajax to send the data to the server. –  Oct 20 '16 at 04:03

1 Answers1

1

Browsers do not send POST data for elements if they have no name. Therefore you cannot get the values of the inputs.

Scopey
  • 6,269
  • 1
  • 22
  • 34