title: PHP How to check if text field matches var
body: <p>Well then, this is likely to be the n-th time someone is asking this, but honestly I didn't grab anything useful spending the last hour or so on Google. What I want to do is rather trivia, or so I thought. I have this working in Java Script but want to move it to PHP. In brief: </p>
  
  <ul>
  <li>declare a var with a static value</li>
  <li>add text field into which user is asked to enter value of above var</li>
  <li>check if field is a) empty, b) non-empty mismatch, or c) non-empty match</li>
  </ul>
  
  <p>My (limited) PHP wisdom has lead me into believing it ought to be something like the below, but apparently it's not. I'd very much appreciate any insight, tha.</p>
  
  <pre><code>&lt;?php
  $coconew = "blah";
  
  if (isset ($_POST["cocosub"])) {
      if ($_POST["cocoval"] == "") {
          echo "empty";
      } else {
          if ($_POST["cocoval"] != $coconew) {
              echo "mismatch";
          } else {
              echo "match";
          }
      }
  }
  ?&gt;
  
  &lt;form action="&lt;?php $_SERVER['PHP_SELF'] ?&gt;" id="cocosub" method="post"&gt;
      &lt;div&gt;
          &lt;?php echo $coconew; ?&gt;
          &lt;input type="text" id="cocoval"&gt;
          &lt;input type="submit"&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>