Simple form but no output

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm new to PHP, and created a simple form, but never get any output.
The two files, form_input.html and form_output.php are:

        <form action="form_output.php" method="post">
            Form input: <input name="name" size="10" type="text">
            <input type="submit" value="Send">


$input = $_POST[ 'name' ];
echo "input = $input";
echo "_POST[ 'name' ] = $_POST[ 'name' ]";

....I don't even see the <h2>form_output.php</h2> displayed.  But PHP is
working, and it tests fine displaying phpinfo().

Any ideas?

Re: Simple form but no output

After you run it and get the blank page for form_output.php, go to View
-> View Source and copy and paste the source code.  If you see
something like:
then there is a syntax error.  You may want to try changing your echo
statements in the form_output.php like this:
$input = $_POST[ 'name' ];
echo 'input = ' . $input;
echo '_POST[ "name" ] = ' . $_POST[ 'name' ];
Putting variable names inside double quoted strings is messy and often
leads to syntax or logic errors.  It also slows down the parser.

Re: Simple form but no output

Thanks, DJ.  You were right:

PHP likes the
    echo "input = $input";
but not the
    echo "_POST[ 'name' ] = $_POST[ 'name' ]";

Perhaps array elements are not interpolated like in Perl.  I'm
definitely new to PHP.

Re: Simple form but no output

If the example code you gave is a copy n paste then I'm sure its not
working because of a typo:

Quoted text here. Click to load it
misses a $ on the first $_POST['name']
There isnt really a need to put a space in the variable name as far as
I'm aware?? and ur code shuld read better without the space.

 - Rob wrote:
Quoted text here. Click to load it

Site Timeline