Creating A Logic In Best Way
<p>can I know... there is a best way to do this logic than I have tried so far???</p>

<p>This is my code...</p>

<pre><code>//------------ Check code search bar form submission ---------------//
if ( isset( $_POST['code_search_submitted'])) {
  if ( isset( $_POST['searchCode']) &amp;&amp; !empty( $_POST['searchText'])) {
    if (is_numeric( $_POST['searchText']) &amp;&amp; (strlen($_POST['searchText']) == 4)) {

       $searchCode = $_POST['searchCode'];
        if ( $searchCode == 1 ) {
          $_SESSION['searchCode'] = 'TutorCode';
        } elseif ( $searchCode == 2 ) {
          $_SESSION['searchCode'] = 'InstituteCode';
        }

        $_SESSION['searchText'] = $_POST['searchText'];

     } else {
       $searchingError= 'Ennter four digits for code!';
       echo '&lt;script type="text/javascript"&gt;';
       echo "alert('" . $searchingError . "')";
       echo "&lt;/script&gt;";
     }


      $url = BASE_URL . 'search/searching.php'; // Define the URL:
      ob_end_clean(); // Delete the buffer.
      header("Location: $url");
      exit(); // Quit the script.

     } else {
       $searchingError= 'Enter Tutor or Institute Code!';
       echo '&lt;script type="text/javascript"&gt;';
       echo "alert('" . $searchingError . "')";
       echo "&lt;/script&gt;";
     }
  } //---- Check code search bar form submission ----//
</code></pre>

<p>any comments are greatly appreciated...</p>

<p>thank you... </p>
