answersLogoWhite

0


Best Answer

You can access all fields posted in the $_POST array. For example, if you have a form like this:

<input type="text" name="foo"></input>

<input type="text" name="bar"></input>

You can get their values by referring to $_POST['foo'] and $_POST['bar'].

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you gather all form input fields with one php function or POST call?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is a correct way to retrieve the lastname input field from a form submitted with a post method?

The correct way is to define an input type. The format for it would be &lt;form action="" type="post"&gt;&lt;input type="text"/&gt;&lt;/form&gt;


How do you submit an HTML form whose method is post using a text link?

the only way to submit a form directly from a link is with the GET method. The POST method will allow form submission only from the form itself. However, it is relatively simple to create a link to a web page with a form using a POST method where the page has a javascript function to submit the form that executes upon page load. You would first need to send the parameters in the GET fashion and then use those values to populate the form input statements. Example function submitForm(){ document.form.submit(); } (.... rest of form here. Load the input values from the link parameters.)


How do you call a PHP function from an onchange equals in an HTML form?

You would have to do this using an AJAX request. The onchange event would trigger a Javascript function that would in turn send a request to the server, and handle the response. This requires a fair bit of back-end code for handling the AJAX, and I would recommend using an existing library for that purpose. jQuery is the one that I am familiar with, and you could handle that change event like so: &lt;?php if(array_key_exists('mytext', $_POST)){ echo "The text you posted is "{$_POST['mytext']}""; exit; } ?&gt; &lt;script src="(jquery source URL here)" type="text/javascript"&gt;&lt;/script&gt; &lt;!-- ... --&gt; &lt;input type="text" id="mytext"&gt;&lt;/input&gt; &lt;div id="result"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; $("#mytext").change(function(){ $.post("myscript.php", {'mytext':$("#mytext").val()}, function(dat){ $("#result").HTML(dat); }); }); &lt;/script&gt;


How do you retrieve data with while query which take left and right value from HTML form from MySQL using PHP?

I'm just going to assume that "left" and "right" are names of an input fields, and that the form type is "POST" in the php file that your form is posted to, you can get these values like this: $left = $_POST["left"]; $right = $_POST["right"]; now $left and $right will have the values from your form, and you can use them as you like.


How do you clear all the values in a form in HTML?

After some discussion, here's a simple way to put the question: [ How do you clear all the values in a form? ] The question isn't asking to reset the values; But to clear them. To answer this question, I will show a very simple form that uses JavaScript to clear the two textboxes in a form, when you press a button. ---- &lt;html&gt;&lt;head&gt;&lt;title&gt;Clearing Forms!&lt;/title&gt; &lt;script type='text/javascript'&gt; function clearForm() { document.loginForm.username.value = ""; document.loginForm.password.value = ""; } &lt;/script&gt; &lt;body&gt; &lt;form name='loginForm' action='login.php' method='post'&gt; &lt;input type='text' name='username' id='username' value='Type Username' size='20' /&gt; &lt;br /&gt; &lt;input type='password' name='password' id='password' value='Type Password' size='20' /&gt; &lt;br /&gt; &lt;br /&gt; &lt;input type='submit' value='Log in' /&gt; &lt;input type='button' onClick='clearForm()' value='Clear Fields' /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; ---- The above HTML + JavaScript outputs two textboxes for user input: One that already says "Type username" and one that says "Type Password". Below them are two buttons; One that submits the information, and another that clears all the information. How does this work? In simple terms, when the normal button is clicked (Not the submit button), the JavaScript function clearForm() (Which is a custom function, created earlier in the &lt;head&gt;) is activated. Whatever clearForm() is said to do, happens. Lets look at what it's actually supposed to do. ---- document.loginForm.username.value = ""; ---- "document" means something's going to change in the output document. "loginForm" is the thing that is changing. "loginForm" is the name of the form the fields are in. "username" is the field that is going to change. "value" is the thing that is going to change in "username". "=" self explanatory. "" means nothing - Null, if you will. That one line of JavaScript will set the username field to empty - Nothing / Null, free to write in again. You should repeat this line as necessary to suit all the input variables you have.

Related questions

What are Two methods data can be submitted to a web server?

The two methods for submitting data to a server GET and POST When ever you open a web page you are using the GET method. POST is primarily used with forms where you input information, though not always. A search engine generally uses the GET method, even though you are entering information into a form. When the GET method is used, the form fields are added onto the URL. In a POST the fields are submitted 'behind the scenes' and not visible to the user.


What is a correct way to retrieve the lastname input field from a form submitted with a post method?

The correct way is to define an input type. The format for it would be &lt;form action="" type="post"&gt;&lt;input type="text"/&gt;&lt;/form&gt;


How do you create a text area to post a query and to get a reply for it?

You can create a text area by the input element. It goes like: &lt;input type="text"/&gt;.


What is the function of a post office?

Public Service


How do you post the data from an input type checkbox in a form to MySQL tables using PHP?

using the post command.$_POST['checkboxname'];


How do you submit an HTML form whose method is post using a text link?

the only way to submit a form directly from a link is with the GET method. The POST method will allow form submission only from the form itself. However, it is relatively simple to create a link to a web page with a form using a POST method where the page has a javascript function to submit the form that executes upon page load. You would first need to send the parameters in the GET fashion and then use those values to populate the form input statements. Example function submitForm(){ document.form.submit(); } (.... rest of form here. Load the input values from the link parameters.)


Where is the auxiliary input in the 2001 Honda Civic?

There isn't one unless you install it post-factory.


Where can one find a Canada Post Office in Montreal?

The Canada Post website offers visitors the possibility to search for post offices in Montreal. Visitors are required to input their postcode or address in order to locate a post office in Montreal.


What is a post sound check function to one direction?

efw


What are the different function performed by post?

To post data of form to another form. there are two functions available post and get. get can carry string of data but post can carry package of data.


Where can you watch movies and tv online?

Please post URLs with the "ADD LINK" button, not in the Answers Fields.


The ex post facto clause does not apply to the legislative function?

yes