title: HTML form with submit to php. Displaying php response
body: <p>I am trying to implement a 'reset password' page for my website. So far I have a simple page with a form for the user to enter their email address. Submitting the form calls 'requestpasswordreset.php' which does things such as checking if there exists a user with that email, sending the password reset email out etc.</p>
  
  <pre><code>&lt;body&gt;
  &lt;form name="input" action="requestpasswordreset.php" method="post"&gt;
      Email Address: &lt;input type="text" name="email"&gt; &lt;/br&gt;
      &lt;input type="submit" value="Submit"&gt;&lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>requestpasswordreset.php pseudocode</p>
  
  <pre><code>if no user with email = $_POST['email']
      echo 'No user exists with this email';
  else
     ...
     doStuff();
     echo 'Password reset email sent';
  </code></pre>
  
  <p>I would like to know how I could do the following:</p>
  
  <p>If the user entered an invalid email address, the form would remain visible and an error message would be displayed. </p>
  
  <p>If the request was successfull the form would be hidden, and a message saying something like 'success' would be displayed.</p>
  
  <p>It seems like it would be unnecessary/bad practice to redirect to a new page in either case? rather than just updating the current one.</p>