title: How to set a $cityError variable properly?
body: <p>I'm wondering what can I do to set a <code>$cityError</code> variable? I think the problem is because my <code>$cityError</code> is under the actual <code>$cityError</code> variable but I have to keep the <code>if</code> statement under my form <code>echo</code>:</p>
  
  <pre><code>echo $cityError . 
   '&lt;form action="" method="POST"&gt;
      &lt;p&gt;Įvertinkite mėnesio orą &lt;/p&gt;
      Miestas: &lt;input type="text" name="cityc"&gt;&lt;br /&gt;&lt;br /&gt;
      Mėnesis: &lt;input type="text" name="month"&gt;&lt;br /&gt;&lt;br /&gt;'; 
      foreach ($weather as $value) {
        echo '&lt;input type="checkbox" name="' . $value . '" value="' . $value . '"&gt; '. ucfirst($value) . '&lt;br /&gt;';
      }
      echo '&lt;br /&gt;&lt;input type="submit" value="Tęsti"&gt;
    &lt;/form&gt;';
  
  if (isset($_POST['cityc']) &amp;&amp; !empty($_POST['cityc'])) {
    if (isset($_POST['month']) &amp;&amp; !empty($_POST['month'])) {
      if (isset($_POST['rain']) || isset($_POST['sunshine']) ||
        isset($_POST['clouds']) || isset($_POST['hail']) ||
        isset($_POST['hail']) || isset($_POST['sleet']) ||
        isset($_POST['snow']) || isset($_POST['wind'])) {
    } else { echo 'Pasirinkite orą!'; }
   }
  } else {
    $cityError = 'Įrašykite miestą!';
  }
  echo 'CIA: ' .$cityError;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/p0xzN.png" rel="nofollow noreferrer">Here is my image of the form until submitting</a></p>
  
  <p>My variable is already set up but I don't want to set it until my form submission.</p>
  
  <p>If I do like this (switching places):</p>
  
  <pre><code>if (isset($_POST['cityc']) &amp;&amp; !empty($_POST['cityc'])) {
    if (isset($_POST['month']) &amp;&amp; !empty($_POST['month'])) {
      if (isset($_POST['rain']) || isset($_POST['sunshine']) ||
        isset($_POST['clouds']) || isset($_POST['hail']) ||
        isset($_POST['hail']) || isset($_POST['sleet']) ||
        isset($_POST['snow']) || isset($_POST['wind'])) {
    } else { echo 'Pasirinkite orą!'; }
   }
  } else {
    $cityError = 'Įrašykite miestą!';
  }
  echo 'CIA: ' .$cityError;
  
  echo $cityError . 
   '&lt;form action="" method="POST"&gt;
      &lt;p&gt;Įvertinkite mėnesio orą &lt;/p&gt;
      Miestas: &lt;input type="text" name="cityc"&gt;&lt;br /&gt;&lt;br /&gt;
      Mėnesis: &lt;input type="text" name="month"&gt;&lt;br /&gt;&lt;br /&gt;'; 
      foreach ($weather as $value) {
        echo '&lt;input type="checkbox" name="' . $value . '" value="' . $value . '"&gt; '. ucfirst($value) . '&lt;br /&gt;';
      }
      echo '&lt;br /&gt;&lt;input type="submit" value="Tęsti"&gt;
    &lt;/form&gt;';
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Y3jAv.png" rel="nofollow noreferrer">Here is my image of the form until submitting</a></p>
  
  <p>It just makes 2 sentences even if I don't submit the form. After for submission, nothing changes.</p>