I have a simple javascript alert box that lets a customer enter some info.
But I need to pass whatever they type to a php variable for later use, and I can't quite figure it out.
Here is what I did:
<html>
<head>
<title>Writing Names</title>
<script language="JavaScript">
var viewer_name = prompt ("Please enter your name.","Type Name Here");
</script>
</head>
<body bgcolor="#ffffff">
<? $test= ?>
<script language="JavaScript">
document.write(viewer_name);
</script>
<?php
echo $test;
?>
As you can see, I have attempted to pass the viewer_name field to the variable: $my_name;
However, I get nothing on the page, and the logs tell me : parse error, unexpected ';' on the same line as <? $test= ?>
Any ideas how to pass a js variable to PHP?