By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

Question from beginner

P: n/a
Hello,
I try to use php, but I have problem with forms.

I have a file named test.php like that:
<FORM ACTION="test.php" METHOD="POST">
type your name, then submit :
<INPUT TYPE=text NAME=name>
<INPUT TYPE=submit VALUE="Submit">
</FORM>
<P>
your name is
<?php
echo "$name";
?>

And I have this error:
Notice: Undefined variable: name in c:\program
files\easyphp1-8\www\epc\test.php on line 9

What's wrong

Thank you.
Antoine

Jun 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Antoine Mérieux" <no************@yahoo.com> wrote in message
news:44**********************@news.free.fr...
| Hello,
| I try to use php, but I have problem with forms.
|
| I have a file named test.php like that:
| <FORM ACTION="test.php" METHOD="POST">
| type your name, then submit :
| <INPUT TYPE=text NAME=name>
| <INPUT TYPE=submit VALUE="Submit">
| </FORM>
| <P>
| your name is
| <?php
| echo "$name";
| ?>
|
| And I have this error:
| Notice: Undefined variable: name in c:\program
| files\easyphp1-8\www\epc\test.php on line 9
|

echo $name

D.
Jun 16 '06 #2

P: n/a
Virginner a écrit :
"Antoine Mérieux" <no************@yahoo.com> wrote in message
news:44**********************@news.free.fr...
| Hello,
| I try to use php, but I have problem with forms.
|
| I have a file named test.php like that:
| <FORM ACTION="test.php" METHOD="POST">
| type your name, then submit :
| <INPUT TYPE=text NAME=name>
| <INPUT TYPE=submit VALUE="Submit">
| </FORM>
| <P>
| your name is
| <?php
| echo "$name";
| ?>
|
| And I have this error:
| Notice: Undefined variable: name in c:\program
| files\easyphp1-8\www\epc\test.php on line 9
|

echo $name

D.

It's wrong again.
It's very bizarre!
Jun 16 '06 #3

P: n/a
Antoine Mérieux wrote:
Hello,
I try to use php, but I have problem with forms.

I have a file named test.php like that:
<FORM ACTION="test.php" METHOD="POST">
type your name, then submit :
<INPUT TYPE=text NAME=name>
<INPUT TYPE=submit VALUE="Submit">
</FORM>
<P>
your name is
<?php
echo "$name";
?>

And I have this error:
Notice: Undefined variable: name in c:\program
files\easyphp1-8\www\epc\test.php on line 9

What's wrong

Thank you.
Antoine

Antoine,
There are really three things wrong with the code you have sent us:
1. it needs to be contained within an <html> tag set (i.e. valid html)
2. the values to the attributes should be in quotes
3. the value of the input tag 'name' is contained in $_POST['name'], not
$name.

Here is your code reworked so that it does what you expect:
<html>
<head></head>
<body>
<form action="test.php" method="POST">
type your name, then submit:
<input type="text" name="name">
<input type="submit" value="Submit">
</form>
<p>
your name is <?php echo $_POST['name'];?>
</body>
</html>

-david-
p.s. I use lowercase because I don't like code SHOUTING at me ;-)

Jun 16 '06 #4

P: n/a
Antoine,

There are a little bit more information about why to use $_POST['name']
instead of $name:
http://php.net/register_globals

Sincerely,
Alexander
http://www.alexatnet.com/

Jun 16 '06 #5

P: n/a
AlexVN a écrit :
Antoine,

There are a little bit more information about why to use $_POST['name']
instead of $name:
http://php.net/register_globals

Sincerely,
Alexander
http://www.alexatnet.com/

Thank you very much. I think it's the good way.
But now it's late, time to bed, I'll see it tomorrow.
Tomorrow is another day
bye
Jun 16 '06 #6

P: n/a
Thank you David.
It's the solution
Superb
Jun 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.