title: PHP contact form keep input fields if error, otherwise clear
body: <p>I want my contact form input fields to save the user's inputs if there's an error, otherwise have them cleared if the email goes through. Right now it works except when the email is sent the fields are still filled in. I could refresh the page but then it doesn't show the 'Your email has been sent' message.</p>
  <p>Here's my form:</p>
  <pre><code>&lt;form class=&quot;contact-form&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
  &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;&lt;?php if(isset($_POST[&quot;name&quot;])) echo $_POST[&quot;name&quot;]; ?&gt;&quot; /&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I tried adding something to my php code that handles the email business - if the message was sent, <code>unset($_POST[&quot;name&quot;])</code>, and also adding to this form input's php <code>else echo '';</code> but that didn't seem to work. It seems the variable was still set.</p>