-3

I am trying for reset password module in a project. The resetpwd.php file gets the reset password and passing on the form variables to the updatepwd.php file for updating into database. $_POST function is called successfully when submit key is pressed but form variables are not passed on the updatepwd.php file.

resetpwd.php

<form id='frdpwd' method ="post"  action="/updatepwd.php" autocomplete="off">
<label for="Name">Name :</label>
<input type="text" id="name" name="name" disabled = "disabled" size =25 value="<?php echo $name; ?>" >
<label for="email">Email ID :</label>
<input type="email" id="email" name="email" disabled = "disabled" size =25 value="<?php echo $email; ?>" >
<input type="password" id="pwd" name="pwd" size = 25 placeholder="Your password (Required).." onkeyup='check();'>
<input type="submit" name = "resetpwdsubmit" value="Submit" >
<input type="reset" value="Reset">
</form>

updatepwd.php
<?php
    if(isset($_POST["resetpwdsubmit"])){
    $rname = $_POST["name"]);
    $remail = strtolower($_POST["email"]);
    $rpwd = $_POST["pwd"];
    $rcpwd = $_POST["cpwd"];

    echo "<script type='text/javascript'>alert('Check : " . $rname . "');</script>"; 

        if($rpwd==$rcpwd && $rname!="" && $remail!="" && $rpwd!=""){
        echo "<script type='text/javascript'>alert('ready to update the pwd : " . $_POST["pwd"] . "');</script>"; 
        }
    }
?>
ndm
  • 59,784
  • 9
  • 71
  • 110
  • Is this pasted exactly as it is in your file? – Ice76 Jan 31 '18 at 18:59
  • try var_dump($_REQUEST) – jjoselon Jan 31 '18 at 18:59
  • 1
    Maybe because they're `disabled`??? `error_reporting(E_ALL); ini_set('display_errors', '1');` – AbraCadaver Jan 31 '18 at 18:59
  • disable property of course, but we are try get password, not email – jjoselon Jan 31 '18 at 19:01
  • To @AbraCadaver's comment.. from [input#disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-disabled): _"[...] a disabled control's value isn't submitted with the form."_ – FirstOne Jan 31 '18 at 19:01
  • Really? What are you trying to get here: `&& $rname!="" && $remail!=""` ? – AbraCadaver Jan 31 '18 at 19:04
  • Your form doesn't prompt for cpwd and thus the if statement is never true. – Alex Howansky Jan 31 '18 at 19:11
  • I can able to get the variable pwd, but the name and email id which was extracted from the php code and embedded on the form text boxes are not able to pick up in the POST method – Manikandan Raghavan Jan 31 '18 at 19:29
  • @ManikandanRaghavan where is `$email` and `$name` set? – Ice76 Jan 31 '18 at 19:32
  • Also, disabled input fields do not get send in form POST data. https://stackoverflow.com/a/7357314/5749295 – Ice76 Jan 31 '18 at 19:35
  • @Ice76, Thanks for your information. the variables $email and $name is extracted from the database when the form is loading. As you have clearly mentioned the disabled input field can't throw the variables in the POST method. I have used the tag such as to resolve the issue. Again Thanks for your valuable time. – Manikandan Raghavan Feb 01 '18 at 10:18

2 Answers2

1

You are not receiving the fields because disabled form fields do not get sent with the request

You also have a typo:

Change

$rname = $_POST["name"]);

To

$rname = $_POST["name"];
Ice76
  • 1,143
  • 8
  • 16
0

As you have clearly mentioned the disabled input field can't throw the variables in the POST method. I have used the tag such as to resolve the issue. Thanks all for your valuable time.