How to collect data using php from an HTML form?

Suppose there is an HTML file in which there is a form containing some data that has been entered by the user using a text box and a check box. How to send this data to a PHP file?

+4
source share
4 answers

All form variables will be in the $ _GET or $ _POST array in php (depending on which method you use to submit the form.

The text box or check box should be called as follows:

<!-- HTML form --> <form method="post" action="collect.php"> Comments: <textarea name="comments" cols="20" rows="5"></textarea> <br/> Tick to select <input type="checkbox" name="checker"/> </form> // collect.php $comments=""; if(isset($_POST["comments"])) { $comments = $_POST["comments"]; } $checker=""; if(isset($_POST["checker"])) { $comments = $_POST["checker"]; } 
+2
source

you can publish this data by submitting a form, and then to the php file you can use $_POST['fieldname']; to use the value of what you have on the HTML page.

+2
source

Values ​​from the form will be available in the $ _GET and $ _POST arrays, depending on the method used in the form.

+1
source

The form action attribute defines the php script (or other script) to which the form data is sent. You can get the data using $_GET and $ _ POST . In the following example, text inputs will be sent to form_action.php

 <form action="form_action.php" method="get"> First name: <input type="text" name="fname" /><br /> Last name: <input type="text" name="lname" /><br /> <input type="submit" value="Submit" /> </form> 
0
source

All Articles