The $_POST
variable is an array (see $_POST on php.net). This means you can access the inner content like this $_POST['index']
.
For you this would mean that you have to use the form input names with $_POST
. This gives you $_POST['name']
, $_POST['email']
and $_POST['pw']
. These variables contain the input from the form.
Note that just printing/echoing these variables to your website you might have some problems with XSS, you can check this answer or this one (both from other questions) for on how to prevent something like that from happening.
EDIT (after comment):
I suggest you to change (or even remove) your javascript code. Because you are using $('input').each()
you are currently sending 3 separate POST requests to /require/jp/insert.php
, this means the data is handled separately. If you were to change that, your inputs do not have a name, that is why extract()
doesn't work, the data within $_POST
isn't set to a specific 'variable' to use after extract()
.
I suggest you change your code to something like this:
(somehtmlpage.html?):
<form method="POST" action="/require/jp/insert.php">
<input type="text" name="name" placeholder="name">
<input type="text" name="email" placeholder="email">
<input type="password" name="pw" placeholder="pw">
<input type="submit" id="insert">Insert</input>
</form>
(insert.php):
extract($_POST);
print $name.' '.$email.' '.$pw;
What this does is exact the same, without javascript (and the 3 POSTs). Since your data is now within the 'same' $_POST
you can use the names (from the input fields, 'name=....') after extraction.