'$_GET'ing variables

Discussion in 'PHP' started by MCJim, Aug 29, 2008.

  1. #1
    How can I 'get' a variable?

    Example:

    index.php

    <td class="body">
    	<form action="player.php" method="get">
    	<input type="hidden" name="<?php echo $file?>" />
    	<input type="submit" />
    </form></td>
    
    Code (markup):
    player.php
    <?php echo $_GET[$file]; ?>
    Code (markup):
    This example doesn't work, but it shows what I would like to do. Any help is appreciated...
     
    MCJim, Aug 29, 2008 IP
  2. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #2
    With a few little changes, your code will work:

    index.php:
    <?php
    	$file = 'MyFile';
    ?>
    
    <td class = "body">
    	<form action = "player.php" method = "get">
    		<input type = "hidden" name = "filename" value = "<?php echo $file; ?>" />
    		<input type = "submit" />
    	</form>
    </td>
    PHP:
    player.php:
    <?php 
    	echo ($_GET ['filename']); 
    ?>
    PHP:
    If you need more details, please reply.
     
    ForumJoiner, Aug 29, 2008 IP
  3. MCJim

    MCJim Peon

    Messages:
    163
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It worked perfectly, thanks a lot! :D
    I'd give you more reputation, but it says I have to 'spread it around' before giving it to you again.
     
    MCJim, Aug 29, 2008 IP