Jump to content

Unlimited Variables Using $_POST


jj20051

Recommended Posts

I'm building a form using ajax that will allow users to add additional rows to their submissions. The problem however is getting PHP to recognize those variables. So that if the user submits 5 rows, it reads and creates a variable for all 5. I'm pretty sure that doing this will involve some form of while() processing and a total row count, but I'm unsure how to name the variables on the form end and how to receive those into PHP without the script erroring out.

 

Suggestions? I was thinking something along the lines of naming each variable something like "number_title" or as an example "5_title." Then using a while function to pull the data from $_POST[$number.'_title']; or something similar, but I'm unsure if that method would even work.

Link to comment
https://forums.phpfreaks.com/topic/213135-unlimited-variables-using-_post/
Share on other sites

AJAX is not PHP, so the data manipulation is no different than any other PHP script, it is just that the data is sent to the server via javascript.  Make sure you set the POST, or GET properties in your javascript function correctly, and you should be able to retrieve those variables just like any other PHP script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.