title: Javascript not executing with PHP
body: <p>I am playing with PHP, going through some security tutorials. I tried to demonstrate a very basic XSS attack. If I simply use <code>echo "Test&lt;script&gt;alert(1);&lt;/script&gt;";</code>, it displays a javascript alert box, but when I try to <strong>POST</strong> the same text using a form and then echoing it back on the browser doesn't give me javascript alert box. Just displays <strong>Test</strong>.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  
  $text = isset($_POST['text'])? $_POST['text']: NULL;
  if ($text) {
      echo $text;
  }
  
  $test = "Test&lt;script&gt;alert(1);&lt;/script&gt;";
  echo $test;
  ?&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
   &lt;title&gt;Security&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method="POST"&gt;
  &lt;label for="text"&gt;Put some random text here:&lt;/label&gt;
     &lt;input type="text" name="text"&gt;
  
     &lt;input type="submit" name="submit"&gt;
   &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>