In this code first script executes but second script doesn't execute.
<?php
echo "<script>
document.getElementById('pageOne').click();
</script>"; // This doesn't execute
echo "<script>
alert('Unknown user');
</script>"; // This executes
?>
The element was not loaded where I was calling the click() function. Moving the php script to bottom of body did the work.