I have the following code below. I want to know if there is a way to send through the URL a variable that was passed from JS to PHP. The code intension is to pass the variable after clicking the button.
NOTE: The user will be directed to this page described in the link
<html>
<head>
<title>Passar Variável Javascript para PHP</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <scripttype="text/javascript">
var variaveljs = 'Mauricio Programador';
</script>
</head>
<body>
<?php
$nome="<script>
$(function() {
$('#botao').click(function () {
document.write(variaveljs);
});
});</script>";
?>
<div id="botao">
<?php
echo " <a href='pagina2.php?valor='.$nome>Botão</a>";
?>
</body>
</html>