How to echo form values

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pineriver
Forum Commoner
Posts: 50
Joined: Fri Aug 15, 2003 5:24 pm

How to echo form values

Post 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
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

turn the vars into an array. use $_POST and echo them out.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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']);

?>
Post Reply