on 16/05/02 12:24 PM, k spellman ([EMAIL PROTECTED]) wrote:

> The code for form.html is
<snip>
>
> and the code for the HandleForm.php is
> 
> <HTML>
> <HEAD>
> <TITLE>Form Results</TITLE>
> </HEAD>
> <BODY>
> <?php
> 
> /* This page receives and handles the data generated
> by "form.html". */
> print "Your first name is $FirstName.<BR>\n";
> print "Your last name is $LastName.<BR>\n";
> print "Your E-mail Address is $Email.<BR>\n";
> print "This is what you had to say:<BR>\n
> $Comments<BR>\n";
> 
> ?>
> </BODY>
> </HTML>

If you're running PHP4.2 on a new server (1st install), $FirstName will not
work, because register_globals is probably set to Off in your php.ini file.

Try this:

<HTML>
<HEAD>
<TITLE>Form Results</TITLE>
</HEAD>
<BODY>
<?php

/* This page receives and handles the data generated
by "form.html". */
print "Your first name is {$_POST['FirstName']}.<BR>\n";
print "Your last name is {$_POST['$LastName']}.<BR>\n";
print "Your E-mail Address is {$_POST['$Email']}.<BR>\n";
print "This is what you had to say:<BR>\n
{$_POST['$Comments']}<BR>\n";

?>
</BODY>
</HTML>

You have to get the vars out of the $_POST array, not straight out of the
vars like $FirstName.

It may seem like more work, but since you're new to PHP, now would be the
perfect time to get used to the new method, since it's more secure.

If you find it a little messy though, you could also try:

<?php

$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Email = $_POST['Email'];
$Comments = $_POST['Comments'];

/* This page receives and handles the data generated
by "form.html". */
print "Your first name is {$FirstName}.<BR>\n";
print "Your last name is {$LastName}.<BR>\n";
print "Your E-mail Address is {$Email}.<BR>\n";
print "This is what you had to say:<BR>\n
{$Comments}<BR>\n";

?>

Which is a little closer to what you had, with 4 lines added to the top.  I
wrap $vars within "strings" in {these brackets}, because it makes complex
stuff later on easier & clearer.  It's a good habbit to get into.


The above code should work now.  If it doesn't, email me and i'll run some
tests on it.


Justin French
--------------------
Creative Director
http://Indent.com.au
--------------------








> 
> And the book suggested POST instead of GET because it
> is stated that Post is secure and GET is not.
> 
> Thanks,
> spellman
> 
> --- Justin French <[EMAIL PROTECTED]> wrote:
>> Show us the code for processing the form!
>> 
>> My guess is your book uses code with $firstname
>> rather than
>> $_POST['firstname']... given that your version of
>> PHP is probably new
>> (4.2.x), register_globals is prolly OFF in your
>> php.ini config file.
>> 
>> Justin
>> 
>> 
>> 
>> on 16/05/02 12:13 PM, k spellman
>> ([EMAIL PROTECTED]) wrote:
>> 
>>> Just opened a "How to" book today on PHP. Already
>>> having problems and wouldn't mind an extra set of
>>> eyes. My basic form does not produce results.Any
>>> thoughts on this one?
>>> 
>>> http://www.hermengoode.com/php/form.html
>>> 
>>> Thanks!
>>> spellman
>>> 
>>> __________________________________________________
>>> Do You Yahoo!?
>>> LAUNCH - Your Yahoo! Music Experience
>>> http://launch.yahoo.com
>> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to