it's not working... why?

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
Nit
Forum Newbie
Posts: 5
Joined: Mon May 27, 2002 6:00 am
Location: Israel
Contact:

it's not working... why?

Post by Nit »

Hi,
I'm new to php and I'm trying to pass information from a form (html page) to a php page and write the data, simple just to get started...

this is what I did:
<?php
echo ("Your name is: $fName $lName")
?>

on the html page I have a form with two fields:
fName and lName.
why doesn't this work?
Thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

take a look here
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Tiimmy
Forum Commoner
Posts: 38
Joined: Sat Apr 27, 2002 1:56 am
Location: Australia
Contact:

Post by Tiimmy »

Here's an example to work from:

Code: Select all

&lt;?php

if ($submit) { // Check if form has been submitted.
    echo('Your name is: $firstName $lastName.'); // If it has, display form results.
}
else { // If it hasn't, display the form.
    ?&gt;
    &lt;FORM METHOD="post" ACTION="&lt;?=$PHP_SELF?&gt;"&gt;
        &lt;INPUT TYPE="text" NAME="firstName" VALUE="Enter First Name"&gt;
        &lt;INPUT TYPE="text" NAME="lastName" VALUE="Enter Last Name"&gt;
        &lt;INPUT TYPE="submit" NAME="submit"&gt;
    &lt;/FORM&gt;
    &lt;?
}

?&gt;
That should be pretty much self-explanitory, but, if you still require more help, ask away! :D
Nit
Forum Newbie
Posts: 5
Joined: Mon May 27, 2002 6:00 am
Location: Israel
Contact:

now this won't work...

Post by Nit »

I added this:
register_globals=On;
and I got this error:
Parse error: parse error, unexpected '=' in c:\inetpub\wwwroot\php\test1.php on line 8

why?
Tiimmy
Forum Commoner
Posts: 38
Joined: Sat Apr 27, 2002 1:56 am
Location: Australia
Contact:

Post by Tiimmy »

register_globals=On;
That belongs in the php.ini file. That's the file where all of the configuration settings that PHP requires is stored. You can't run a PHP script with that in it. :)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

we can't tell you since we don't know line 8 of your script ;)
Nit
Forum Newbie
Posts: 5
Joined: Mon May 27, 2002 6:00 am
Location: Israel
Contact:

it's alive!!!

Post by Nit »

Thanks everyone, it works! but I'll be back in the future with more questions!
bye
Post Reply