Page 1 of 1

How to echo form values

Posted: Sat Jun 19, 2004 3:33 pm
by Pineriver
Hi, I have a form like this in php on list.php

Code: Select all

echo " <form name="form1" method="post" action="sites.php">";
$i = 1;
  while ($i <= 10){
echo"<input type="text" name="field$i"><br>";
$i++;
}
echo "</form>";
in sites.php I have

Code: Select all

$i = 1;
  while ($i <= 10){
echo"$field$i";
$i++;
}
The problem is that all I see is the numbers 1 through 10 in sites.php.
My question is how can I echo the variables passed by list.php?
Thanks in advance

Posted: Sat Jun 19, 2004 4:23 pm
by tim
turn the vars into an array. use $_POST and echo them out.

Posted: Sat Jun 19, 2004 5:25 pm
by feyd
to give an example of what tim was saying:

Code: Select all

<?php
echo " <form name="form1" method="post" action="sites.php">"; 
for($i = 0; $i < 10; $i++){ 
echo"<input type="text" name="field[]"><br>"; 
} 
echo "</form>";
?>

Code: Select all

<?php

print_r($_POST['field']);

?>