php jquery onclick提交重定向到另一个页面

I'm trying to make this work but there something wrong:

<?php
if(isset($_POST['submit'])){
    echo "<script>location='https://google.com'</script>";
exit();
}
?>

<html>
<head>

<script>
    function onSubmit() {
        document.getElementById('menu_post').value = 'main';
        document.forms['MenuForm'].submit();
    }

</script>

</head>
<body>

<a onclick="onSubmit();return false;" href="javascript:void(0)">Test</a>

<form name="MenuForm" method="post" action="index.php">
    <input type="hidden" id="menu_post" name="menu_post" value="" />
</form>

</body>
</html>

I tried this one [php on submit redirect to another page

But still doesn't work.

Thanks in advance for any help guys.

It should be something like:

if(isset($_POST['submit'])){
    echo "<script>window.location.href='https://google.com'</script>";
    exit();
}

//-----edit-----//

You've actually nothing being posted as 'submit'.

if(isset($_POST['menu_post'])){
    echo "<script>window.location.href='https://google.com'</script>";
    exit();
}