javascript - Why aren't <script> tags not working on this PHP page? -
when try enter
<script type="text/javascript" > alert("hello"); </script> in comment box on php page not alert box. see script in text file, not on webpage. reason <script> isn't executing. have active scripting , javascript enabled on browsers.
my php code: <?php //cfpcomments.php include_once 'cfpheader.php'; if (isset($_post['content'])) { $fp = fopen('comments.txt', 'a'); fwrite($fp, $_post['content'] . "<br />"); fclose($fp); } echo nl2br(file_get_contents('comments.txt')); echo <<<_end <h3>post comment</h3> <form action='cfpcomments.php' method='post'> <textarea name='content' rows ='3' cols='100'></textarea> <br/> <input type='submit' value='post' /> </form> _end; ?> strange. got work, not sure why.
<!doctype html> <html> <head> <title></title> <script type="text/javascript"> alert("hello"); </script> </head> <body> </body> </html> when type in seems work
anyone have idea why???? confused.
your nl2br() translating
<script type="text/javascript" > alert("hello"); </script> to
<script type="text/javascript" ><br/> alert("hello");<br/> </script><br/> and breaking javascript code.
Comments
Post a Comment