I know this may seem stupid, but I am just starting to learn both javascript and php. If I define a variable in javascript is it possible to use it in php? here is my example that I'm working with:
<p id="demo"></p>
<script>
function myFunction() {
var text;
var person = prompt("Please enter your name","");
if (person != null){
text = "Hello";
}
if (person = null){
text = "Error";
}
document.getElementById('demo').innerHTML = text;
}
</script>
<button onclick="myFunction()">Try it</button>
<?php echo $person?>
I am trying to make it so that when they enter the name I can capture it as a php variable. And if they do not enter a name it gives an error message.