Can you do this? Does the confirm data of a <script></script>
go to the URL? To work in PHP using $_GET[""];
Can you do this? Does the confirm data of a <script></script>
go to the URL? To work in PHP using $_GET[""];
Yes!
You can do it in 2 ways, choose the one that best suits what you want:
Redirects to a PHP page by passing the Query String name
var nome = prompt("Informe seu nome");
window.location.href='arquivo.php?nome='+nome;
Sending via Ajax
jQuery:
var nome = prompt("Informe seu nome");
$.ajax({
url: 'arquivo.php',
type: 'GET',
data: {nome: nome},
success: function(resposta){
alert(resposta);
}
});
Getting the data passed in the URL:
<?php
echo 'O nome informado é '.$_GET['nome'];
?>