my code-
<?php
session_start();
$_SESSION['errors']="failed";
?>
<head>
function myfunc()
{
alert(<?php echo $_SESSION['errors']; ?>);
}
</head>
<body onload="myfunc();">
but alert msg is not popping up.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two errors in your code:
<script>tagsTry this:
You might want to put the
myfunc()inwindow.loadevent or someclickevent to test it. Additionally, as rightly suggested by ThiefMaster, you may want to use theaddslashesfunction for the$_SESSION["errors"]in thealert.Note: It is assumed that file extension for your code is php.