title: php access session variable value in html code
body: <p>what i would like to achieve is to print php session variable on html <code>form.Above</code> is the form where i am trying to print the <code>valid_firm Session</code> variable but the way it is used to print the variable is not working... 
  <em>newFirm-form.php</em></p>
  
  <pre><code>&lt;!DOCTYPE&gt;
   &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta content="no-cache" http-equiv="cache-control"&gt;&lt;/meta&gt;
    &lt;/head&gt;
  
  &lt;body&gt;
    &lt;form id="firm-form" method="post" /&gt;
        &lt;p&gt;Firm Name&lt;/p&gt;&lt;input class="firm-name" type="text" name="firm-name"  /&gt;
  
        &lt;p&gt;Email&lt;/p&gt;&lt;input type="text" name="firm-email" /&gt;
        &lt;p&gt;Telephone&lt;/p&gt;&lt;input type="text" name="telephone" /&gt;
        &lt;p&gt;Address&lt;/p&gt;&lt;input type="text" name="address" /&gt;
        &lt;p&gt;City&lt;/p&gt;&lt;input type="text" name="city" /&gt;
        &lt;p&gt;Firm Code&lt;/p&gt;&lt;input type="text" name="firm-code" /&gt; &lt;br/&gt;
    &lt;/form&gt;
    &lt;?php print $_SESSION["valid_firm"]; ?&gt;
    &lt;input class="submit" type="submit" value="Submit"&gt;&lt;br /&gt;
    &lt;span class="error" style="display:none"&gt; Please Fill The Empty Fields&lt;/span&gt;
    &lt;span class="success" style="display:none"&gt; Form Submitted Success&lt;/span&gt;
  
  
  &lt;/body&gt;
  &lt;footer&gt;
    &lt;script type="text/javascript" src="../js/libs/jquery-1.11.3-min.js"&gt;     &lt;/script&gt;
    &lt;script type="text/javascript" src="../js/newFirm.js"&gt;&lt;/script&gt;
    &lt;/footer&gt;
  
   &lt;/html&gt;
  </code></pre>
  
  <p>javascript file with ajax post method call to submit the form</p>
  
  <pre><code>  $(document).ready(function() {
       var empty_fields = 0;
       $(".submit").on("click", function(){
         $("#firm-form *").filter(":input").each(function(){
        if(!$(this).val()){
        empty_fields += 1;
      }
    });
    if(empty_fields &gt; 0){
      $(".error").fadeIn(800).show();
      $(".success").fadeOut(800).hide();
    }
    else {
      var firm_name = $(".firm-name").val();
      $.ajax({
        type:"POST",
        url:"../registration-control/register-firm.php",
        data: "firm_name=" + firm_name,
        success: function(){
          $(".success").fadeIn(800).show();
          $(".error").fadeOut(800).hide();
        }
      });
    }
    empty_fields = 0;
      });
  
    });
  </code></pre>
  
  <p>and the php file to save the session variable</p>
  
  <pre><code>&lt;?php
  if (isset($_POST["firm_name"])){
    validateName($_POST["firm_name"]);
  
  $_SESSION["firm"] = $_POST["firm_name"];
   //echo $_SESSION["firm"]." from register-firm";
    }
  
     function validateName($firm_name){
         var_dump($firm_name);
        if (preg_match("/^[A-ZΑ-Ω]{1}[a-zA-Zα-ωΑ-Ω0-9\.]*/", $firm_name) &amp;&amp;         !ctype_digit($firm_name)){
       $_SESSION["valid_firm"] = 1;
     }
     $_SESSION["valid_firm"] = 0;
    }
   ?&gt;
  </code></pre>