I wanna if user click "2nd page" and then a message pop up. But why the function cant work?? If someone know why pls tell me!! T__T This is my code: <?PHP require_once('conn.php'); ?> <?php //session_start(); //echo $_SESSION['p_level']; ?> <script language="JavaScript"> function CheckLevel() { var p_level = "<?php $_SESSION['p_level']?>"; if(p_level == 1) { alert("Sorry You cannot access!"); } else { return true; } } </script> <body> <table width="784" border="1"> <tr> <td align="center" scope="row"><a href="1st_Page.php">1st Page</a></td> <td align="center"><a href="2nd_Page.php" onclick="return CheckLevel();">2nd Page</a></td> <td align="center"><a href="3rd_Page.php">3rd Page</a></td> </tr> </table> </body>
Try this: <td align="center"><a href="#" onclick="document.location.href='2nd_Page.php'; CheckLevel();">2nd Page</a></td> Code (markup):