title: Updating specific column in a particular row in mysql using php?
body: <p>I have been trying to create a reset password feature for my website, where the user can insert the already registered email and that will generate a random OTP and will be stored in the same column as the user's details such as </p>
  
  <pre><code>id firstname lastname username email resetpassword
  1  name      last     user     email OTP
  </code></pre>
  
  <p>this is my code but it's not working. </p>
  
  <pre><code>&lt;?php
  require 'dbh.php';
  session_start();
  
  $random = mt_rand(1000,1000000);
  
  $email = $_POST['email'];
  
  $sql = "SELECT Email FROM registeredusers WHERE Email='$email'";
  $result = mysqli_query($connection,$sql);
  $emailCheck = mysqli_num_rows($result);
  
  if (empty($email))
  {
      echo "please fill out all the fields";
  }
  
  else{
  
      $result = mysqli_query($connection,$sql);
      $sql = "UPDATE registeredusers SET ResetPassword='$random' WHERE Email='$email'";
  Header("Location: submitOTP.php");
  }
  
  ?&gt;
  </code></pre>
  
  <p>I am just trying this out so the form looks something like this</p>
  
  <pre><code>&lt;form action="resetPassword.php" method="POST"&gt;
  
  &lt;input type="text" value="email" name="email"&gt;&lt;/input&gt;
  &lt;input type="submit" value="submit"&gt;&lt;/input&gt;
  
  &lt;/form&gt;
  </code></pre>