title: issue with breaking loop in php
body: <pre><code>if((isset($_POST['page_id'])) &amp;&amp; (isset($_POST['page_title'])) &amp;&amp; (isset($_POST['page_file_name']))) {
      $_POST['page_id'];
      $page_id = $_POST['page_id'];
      $page_title = $_POST['page_title'];
      $page_file_name = $_POST['page_file_name'].".txt";
  
      //to check if id or page already exists in database or not
      $sql_page_check = "SELECT * FROM page";
      $sql_page_check_result = mysqli_query($conn,$sql_page_check);
      if($sql_page_check_result == true){
          if(mysqli_num_rows($sql_page_check_result)&gt;0){
              $pages_present =  mysqli_num_rows($sql_page_check_result);
  
              while($page = mysqli_fetch_assoc($sql_page_check_result)){
                  if(($page['page_id']==$page_id) || ($page['page_title']==$page_title) || ($page['page_file_name']==$page_file_name)){
                      echo "Page Id ($page_id) /$page_title / $page_file_name already exists in database, please check and try again";
                      break1;
                  }
                  elseif(($page_id=="") || ($page_title=="") || ($page_link=="")){
                      echo ("&lt;b style='color:red;'&gt;Please fill all fields.&lt;/b&gt;");
                      break;
                  }
  
                  else{
                      if(!file_exists("../pages/".$page_file_name)){
                          fopen("../pages/".$page_file_name,"w");
  
                          $sql_add_menu = "INSERT INTO page VALUES('$page_id','$page_title','$page_file_name')";
  
                          $sql_add_menu_result = mysqli_query($conn,$sql_add_menu);
  
                          if($sql_add_menu_result == true){ 
                              echo"&lt;b style='color:green;'&gt;$page_title Page Added&lt;/b&gt;";
                          }
                      }
                  }
              }   
          }
      }
  }
  include "footer.php";
  </code></pre>
  
  <p>the issue is every error message which has to be displayed is within the loop and gets displayed many times , if i use break,die,exit the footer.php at bottom doesn't shows up and also else part doesn't work !  </p>