I have a modifypassword form that modifys the password in a flat file for a user.( I know its not safe etc. ).
So the thing is: whenever I click on modify password on my website, I get a prompt that asked to enter a new password. All fine, after that it will submit the form. But I cannot get the variable somehow that is typed in. I want to $_GET['newpw'] so I can use it to adjust my flat file.
So I have a form like this:
echo "<td> <form action=\"admin.php\" method=\"GET\" onsubmit=\" modifyPassword();\">
this is the modifyPassword function:
<script type="text/javascript">
function modifyPassword() {
var newpw=prompt("Enter a new password");
if(newpw !== null) {
$.ajax({
type: "GET",
url: "admin.php",
data: {data: newpw},
success: function(data) {
console.log(data);
}
});
}
}
</script>
And when the form is actually submitted I want to get the value from what is typed in like this:
echo $_GET['data'];
This is all in the same file. The output of $_GET['data'] does not show anything. The rest just works fine when I choose a static password like: "test". It will update my flat file, but I want to get the user input to change the password.
Can someone tell me what i am doing wrong?
sending
data so use $_GET['data'].