How to collect data using php from an HTML form?

后端 未结 4 1454
死守一世寂寞
死守一世寂寞 2021-01-19 12:05

Suppose there is a HTML file that has a form in it , which contains some data , which have been taken input from the user using textarea and checkbox . How do I send this da

相关标签:
4条回答
  • 2021-01-19 12:51

    The values from the form will be available in either, the $_GET and $_POST arrays, depending on the method used in the form.

    0 讨论(0)
  • 2021-01-19 12:52

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

    The textarea or checkbox need to be named like this:

    <!-- 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"]; }
    
    0 讨论(0)
  • 2021-01-19 12:57

    you can post this data by submitting form and then on the php file you can use $_POST['fieldname']; for using value what you have on HTML page.

    0 讨论(0)
  • 2021-01-19 12:59

    The action attribute of a form defines the php script (or other script) the form data gets send to. You will be able to get the data using $_GET and $_POST. In the following example the text inputs will get submitted 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 讨论(0)
提交回复
热议问题