sorry but i think you may have misunderstood the way php and javascript interact.
in your code you execute php inside <noscript> tags. this will not determine if noscript is true or not.
one way to do this would be for your first page to call a php image, as in
<script>
document.write("<img src=dummy.php height=1 width=1>");
</script>
where dummy.php sets a cookie, i.e.
setcookie("scriptenabled", 1);
in all other scripts on the site you can check for javascript on the browser by using the condition if ($scriptenabled)
e.g.
if ($scriptenabled)
{
echo "<script> alert ('hey this works');</script>";
}
else
{
echo "you dont have javascript";
}
hope this makes sense 😉