How to get input field value using PHP

php

Solution

Use PHP's `$_POST` or `$_GET` superglobals to retrieve the value of the input tag via the name of the HTML tag.

For Example, change the method in your form and then echo out the value by the name of the input:

Using `$_GET` method:

<form name="form" action="" method="get">
  <input type="text" name="subject" id="subject" value="Car Loan">
</form>

To show the value:

<?php echo $_GET['subject']; ?>

Using `$_POST` method:

<form name="form" action="" method="post">
  <input type="text" name="subject" id="subject" value="Car Loan">
</form>

To show the value:

<?php echo $_POST['subject']; ?>

Problem

I have a input field as follows: ``` <input type="text" name="subject" id="subject" value="Car Loan"> ``` I would like to get the input fields value `Car Loan` and assign it to a session. How do I do this using PHP or jQuery?

Original source