English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

when i enter something into the textbox and press submit
on the next page the echo isnt echoing anything.
i tried on both ie and firefox. i also tried echoing like this:
echo $_POST[$name]; and nothing shows.
what am i doing wrong?
--------------------------------------------------------------------------
filename: form.html



Empty











-------------------------------------------------------
filename: resultsbyname.php

echo $name;
?>

2007-11-15 17:39:38 · 3 answers · asked by sarmenhbb 1 in Computers & Internet Programming & Design

Thank you..

this worked:
$name = $_POST['name'];
echo $name;
?>

2007-11-15 17:52:56 · update #1

im viewing a video by vtc, seems like some code he's using is outdated :-)

2007-11-15 17:59:44 · update #2

3 answers

A form is sent to another (or the same) php file using POST or GET.
The variables sent must be read by the receiving file: you don't read them in your code...
Two examples: the first uses two files, the second uses only one. Spaces are added for clarity (and YA line stripper!)
form.htm
-------------------------

...









------------------------
results.php
------------------------

...

echo ( $_POST [ ' name ' ] . "
");
?>

---------------------------
(your echo line is incorrect)
-------------------------------------------
Sample 2: the SAME file calls itself.
-------------------------------------------
form.php
-------------------------


function showform ( $_POST )
{
echo ( '
' ) ;
echo ( '
' ) ;
echo ( '
' ) ;
echo ( '
' );
}
function showresults ( $_POST )
{
while ( list ( $name , $value ) = each ( $_POST ) )
$$name=$value; // extract all variables from $_POST
echo ( $name . "
") ;
unset ( $_POST ); // clear the post!
}
?>


if ( isset ($_POST [ ' name' ] ) )
showresults ($_POST) ;
else
showform ( ) ;
?>


-------------------------
PS: use "< br space - slash - >" (YA bugs it... again... )

2007-11-15 19:11:08 · answer #1 · answered by just "JR" 7 · 0 0

You have to retrieve the value from the form first.

$name = $_POST['name'];
echo $name;
?>

2007-11-15 17:48:57 · answer #2 · answered by catbertnc 5 · 1 0

Change the name of the textbox to something else like name_text.

I think its sue to the fact that name is also a reserved keyword in PHP and HTML

2007-11-15 17:49:30 · answer #3 · answered by Anonymous · 0 1

fedest.com, questions and answers