Pass variable from PHP to HTML
html, php
Solution
You are getting the variable `$mymp3` with `$_GET` while you are using `<form method='post'..`, change it to `$mymp3 = $_POST['mp3name']`;
Then, change your player.html extension to player.php to use PHP code on it.
So, when you have your player.php file, change this...
<audio id="player" src="$mymp3" autoplay preload="auto"> </audio>
to this...
<audio id="player" src="<?php echo $mymp3 ?>" autoplay preload="auto"> </audio>
Problem
I have a page, `play.html`: ``` <form method="post" action="play.php"> <input type="hidden" name="mp3name" value="/MP3/1.mp3"> <input type="submit" value="Play My MP# #1" /> </form> <form method="post" action="play.php"> <input type="hidden" name="mp3name" value="/MP3/2.mp3"> <input type="submit" value="Play My MP# #2" /> </form> ``` This calls another page, `play.php`: ``` <?php $formurl = "play.html" ; $playerurl = "player.html" ; $mymp3 = $_GET["mp3name"]; header( "Location: $playerurl?mp3name=$mymp3" ); exit ; ?> ``` Then it calls another page, `player.html`: ``` <audio id="player" src="$mymp3" autoplay preload="auto"> </audio> <div> <button onclick="document.getElementById('player').play()">Play</button> <button onclick="document.getElementById('player').pause()">Pause</button> <button onclick="document.getElementById('player').volume+=0.1">Volume Up</button> <button onclick="document.getElementById('player').volume-=0.1">Volume Down</button> </div> ``` How do I pass a variable from PHP to `player.html`?