Display javascript code as string in php file
I am trying to echo javascript code in php. I want to show the java script code as a string that will not be executed. I have the following code in my temp.php file:
<?php
if (count($_POST) > 0)
{
$text = $_POST['text'];
echo $text;
}?>
<html>
<head>
</head>
<body>
<form action="temp.php" method="post">
Text : <br /><textarea name="text" rows="3" cols="50"></textarea>
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
I am taking the following input:
<script>alert("hello");</script>
when i submit the form the browser executes javascript and gives a warning message, but i want to print the code as string. I tested this code in "firefox". Please give me a link. Thank.
+3
source to share