Pass JavaScript prompt variable to input text using PHP [duplicate]

I have a simple page written with (php + html) I just want user enter value into prompt box then when click button the value send to textbox. I tried below code but I get error inside textbox.

<?php
    echo "<script>var age=prompt('Enter your age')</script>";
    $age="<script>document.write(age)</script>";
    echo $age ; 
?>

<html>
   <input type="text" name="age" id="age" value="<?php echo ($age) ; ?>"  >
</html>