Hi there,
I've just started learning php and I hope you guys could help me with
this problem. I've found a useful pice of code from a book to make a form
and I would like to use it. I would like to print the variables (input)
on the screen , but I can't make it work. I think I have to do something
with an array, but don't know what. I've tried
$field = $_POST['field'];
echo $field;
and also
$arr = $_POST['array'];
print_r($arr);
but it doesn't work.
Could some one show me what I'm missing?
Thanks a bunch!
Phi
############### ############ code ############### ############### #####
<?php
// new function
echo "<br><br><h4>se cond function</h4>\n";
function print_form($act ion="", $method="post")
{
if (empty($action) ){return FALSE;}
echo "<form action=$action method=$method> \n";
$numargs = func_num_args() ;
for($i = 2; $i < $numargs; $i++)
{
echo "$i <input type = text name =". func_get_args($ i) . ">
<br>\n";
}
echo "<input type=submit>";
echo "</form>";
}
print_form("aut oform2.php", "", "field", "field2", "field3", "field4");
// testing if the variable exist...and it doesn't...
if(isset($_POST['field'])){
echo "exist";
}
else {
echo "does not exist!";
}
?>
############### ############ end code ############### ############### ####
I've just started learning php and I hope you guys could help me with
this problem. I've found a useful pice of code from a book to make a form
and I would like to use it. I would like to print the variables (input)
on the screen , but I can't make it work. I think I have to do something
with an array, but don't know what. I've tried
$field = $_POST['field'];
echo $field;
and also
$arr = $_POST['array'];
print_r($arr);
but it doesn't work.
Could some one show me what I'm missing?
Thanks a bunch!
Phi
############### ############ code ############### ############### #####
<?php
// new function
echo "<br><br><h4>se cond function</h4>\n";
function print_form($act ion="", $method="post")
{
if (empty($action) ){return FALSE;}
echo "<form action=$action method=$method> \n";
$numargs = func_num_args() ;
for($i = 2; $i < $numargs; $i++)
{
echo "$i <input type = text name =". func_get_args($ i) . ">
<br>\n";
}
echo "<input type=submit>";
echo "</form>";
}
print_form("aut oform2.php", "", "field", "field2", "field3", "field4");
// testing if the variable exist...and it doesn't...
if(isset($_POST['field'])){
echo "exist";
}
else {
echo "does not exist!";
}
?>
############### ############ end code ############### ############### ####
Comment