Questions about passing variable through Javascript from one html page to another page

Hello everyone, my name is Magnus. I am stuck on a question by developing the website. I have found a useful program on the internet, but I did not know how to change the codes into my situation. My codes are shown here:(’_____’ are the parts I do not know how to finish)

Html code:

<body>
    <input type='input' name='nick' id='nick'>
    <a href='test.php'>button</a>
    <script src="https://ajax.google.apis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script>
         _______________;
    </script>
</body>
PHP code (Although Javascript and PHP codes should not be put into the same program, it worked):
<script>
    var test=_____________;
</script>
<?php
echo"<script>document.writeln(test);</script>";
?> 
</body>

Would you mind to answer me how to fill in those blanks? Thanks for your help!

Links I have referenced:

The method used to pass the variable through javascript from one HTML page to another page:
https://stackoverflow.com/questions/27765666/passing-variable-through-javascript-from-one-html-page-to-another-page

The link proves that the PHP code works:
https://www.tutorialspoint.com/How-to-pass-JavaScript-variables-to-PHP

3 posts were merged into an existing topic: Questions about Javascript, PHP and MySQL