title: Inject PHP into Value attribute via Javascript
body: <p>I am trying to inject a value stored in a PHP $_SESSION variable into the "value" attribute of an input tag using javascript. I am able to successfully inject the PHP code in the "value" attribute, but the stored value does not appear in the text box. My code is below:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" name="fname" value="" /&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>fields.eq(n).attr('value', "&lt;?php echo $_SESSION['fname'] ; ?&gt;");
  </code></pre>
  
  <p>The problem is that this would <strong><em>usually</em></strong> place the value of the <code>$_SESSION['fname']</code> variable in the input box. But that is <em>not</em> the case. When the button is clicked to inject the PHP code into the value attribute, this is what the HTML looks like:</p>
  
  <pre><code>&lt;input type="text" name="fname" value="&lt;?php echo $_SESSION['fname'] ; ?&gt;" /&gt;
  </code></pre>
  
  <p>And this is what I want it to look like but in the text box, it actually shows the PHP code and not the value stored in <code>$_SESSION['fname']</code>. </p>
  
  <p>Is there something I am missing? Shouldn't this work? Any help is appreciated!</p>
  
  <p><img src="https://i.stack.imgur.com/RbgPm.png" alt="enter image description here"></p>