title: how to differentiate between different inputs in the same html form using php
body: <p>I'm building a chatbot in php I want the functionality of that chatbot to be that it is used for resetting the password, so it asks for employee's <code>PIS_CODE</code> which it uses as a primary key to change the password in the password column, you can see my database table.</p>
  
  <p><a href="https://i.stack.imgur.com/2RVPi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2RVPi.png" alt="enter image description here"></a></p>
  
  <p>see it has columns <code>PIS_CODE</code> and password, so I ask the user for <code>PIS_CODE</code> and then it asks the user for the new password and then it changes the password in the corresponding column</p>
  
  <p>so I've been able to take the <code>PIS_CODE</code> and use it as a primary key to reset the password but the password which is reset is the <code>PIS_CODE</code> itself</p>
  
  <p><a href="https://i.stack.imgur.com/bDHUk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bDHUk.png" alt="enter image description here"></a></p>
  
  <p>see here I wanted to reset the password for 41000000 <code>PIS_CODE</code> but it reset the password to 41000000 itself. So it seems like my chatbot assumes the input value to be the pis code and it updates the password column with that value only, so my chatbot is not able to differentiate between different inputs. Plus I want to use only a single form and a single input field.
  you can see my chatbot here.</p>
  
  <p><a href="https://i.stack.imgur.com/RqadF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RqadF.png" alt="enter image description here"></a></p>
  
  <p><strong>HTML Code :</strong></p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;form action="process.php" id="form" name="f2" method="POST" &gt;
      &lt;input type="textarea" id="tt" name="input" placeholder="Type Your Message" style="position:absolute; bottom:0; height:30px; width:100%; height:50px;" required /&gt;
  
  &lt;/div&gt;
  
  // this is the code which takes the input for the PIS_CODE
  $msgg=$_POST['input'];
  
  // this is the code which takes the input for the password
  $pass=$_POST['input'];
  
  // the problem is it saves the same input(that is PIS_CODE) in both the variables($msgg and $pass)
  </code></pre>
  
  <p><strong>FULL Code:</strong></p>
  
  <pre><code>&lt;?php
  require_once("config.php");
  $msgg=$_POST['input'];
  $msg=strtolower($msgg);
  $ID = $msg;
  $length=strlen($msg);
  $flag=0;
  
  $pass=$_POST['input'];
  $update = "UPDATE lala SET password='$pass' WHERE PIS_CODE=".$msg;
  $res_4=mysqli_query($con,$update);
  
  $sql1 = "SELECT * FROM lala WHERE PIS_CODE='$msg'";
  $res_u = mysqli_query($con, $sql1);
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;style&gt;
  .in
  {
     background-color:rgb(64,128,255);
     color:white;
     padding:10px; 
     right:0;
     width:130px;
     text-align: center;
     height:auto;
     border-radius: 5px;
     margin-left: 120px;
     margin-bottom: 5px; 
  }
  .out
  {
      background-color:rgb(241,240,240);
      color:black;
      padding:10px; 
      left:5; 
      width:130px;
      text-align: center;
      height:auto;
      border-radius: 15px;
  }
  &lt;/style&gt;
  &lt;body&gt;
  &lt;div class="in"&gt;
  &lt;?php echo "$msgg"; ?&gt;
  &lt;/div&gt;&lt;br&gt;
  &lt;div class="out"&gt;
  &lt;?php
  
  if (($_POST['input']) =='password reset') 
  {
  echo "Do you want to reset your password? "; 
  }
  else if (($_POST['input']) =='yes') 
  {
  echo "Sure, Please provide PIS code ";   
  }
  if (mysqli_num_rows($res_u) == 1) 
  {
  echo 'Pis verified';
  echo "Enter new password";
  }
  
  if($update){//if the update worked
  
        echo "Update successful!";
  
  
  
      } 
   ?&gt;
  &lt;/div&gt;&lt;br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>