Retrieve password from a html-form
I have a html-form which looks like this:
<form action="lib/AdminPage.php" method="post" id="adminLogin">
Admin-Login: <input type="password" name="pw" v开发者_JS百科alue="" class="pw">
<input type="submit" value="Login">
AdminPage.php contains the following lines:
<?php
echo($_GET['pw']);
echo($_GET['adminLogin']);
echo($_GET['Login']);
echo($_GET['id']);
echo($_GET['value']);
echo($_GET['name']);
echo($pw);
echo($_GET["pw"]);
echo($_GET["adminLogin"]);
echo($_GET["Login"]);
echo($_GET["id"]);
echo($_GET["value"]);
echo($_GET["name"]);
?>
None of the echoes works, it's always an "Undefined index
" or "Undefined variable
" with echo($pw)
How can I retrieve the entered string from the from?
Regards
Use $_POST
instead of $_GET
, because you have method="post"
in your form.
You are sending the form using POST
but looking for GET
variables. Replace $_GET
with $_POST
.
Since you have method="post"
in your form <form action="lib/AdminPage.php" method="post" id="adminLogin">
, variables are accessed as _POST
variables. So, you should do
echo $_POST['pw'];
All you need to do is this:
echo $_POST['pw'];
Your HTML form has method="post" in it so you get all information from inputs via $_POST instead of $_GET.
use the $_POST
array, not $_GET
Your form uses the POST
HTTP method, hence this should work.
echo($_POST['pw']);
echo($_POST['adminLogin']);
echo($_POST['Login']);
echo($_POST['id']);
echo($_POST['value']);
echo($_POST['name']);
You need to post the values. But, you are trying to get those through $_GET.
Try changing everywhere $_GET
by $_POST
Change like this :
echo($_POST['pw']);
echo($_POST['adminLogin']);
echo($_POST['Login']);
echo($_POST['id']);
echo($_POST['value']);
echo($_POST['name']);
精彩评论