Fetching URL vars into form and submitting to other page

41 views Asked by At

I have this url: torneioJogo.php?equipaleft=24&equiparight=25&torneioid=8

The following code is in this url...

<form method='GET' action='torneioJogoSub.php?'>

//THESE INPUTS DOWN HERE
<input type="hidden" name="equipa1" value="<?php $_GET['equipaleft'] ?>">
<input type="hidden" name="equipa2" value="<?php $_GET['equiparight'] ?>">
<input type="hidden" name="torneioid" value="<?php $_GET['torneioid'] ?>">

<div id="pontos">
<input type="submit" name="win1" value="<=Vencedor">
<input type="submit" name="emp" value="Empate">
<input type="submit" name="win2" value="Vencedor=>">
<br>
<=Pontos=><br>

//AND THESE INPUTS DOWN HERE
<input type="text" name="pontos1" size="3">
<input type="text" name="pontos2" size="3">

<br>
</div>
</form>

When I submit the form, I need all the data from those inputs in the next page where I have this:

echo "equipa1: " . $_GET['equipa1'];
echo "equipa2: " . $_GET['equipa2'];
echo "torneioid: " . $_GET['torneioid'];
echo "pontos1: " . $_GET['pontos1'];
echo "pontos2: " . $_GET['pontos2'];

What happens is $_GET['pontos2'] and $_GET['pontos1'] work but the values from the hidden inputs (which are being pulled from the url variables), echo nothing. What's happening? Is this a problem with GETs and POSTs or am I missing something else?

2

There are 2 answers

1
georaldc On BEST ANSWER

You need to echo the values out

<input type="hidden" name="equipa1" value="<?php echo $_GET['equipaleft'] ?>">
<input type="hidden" name="equipa2" value="<?php echo $_GET['equiparight'] ?>">
<input type="hidden" name="torneioid" value="<?php echo $_GET['torneioid'] ?>">
0
Steve On

You need to actually output the variables into the form fields

<input type="hidden" name="equipa1" value="<?php echo $_GET['equipaleft'] ?>">
                                                 ^^^^