473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question from beginner

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
6 1066
"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
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
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
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
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
Thank you David.
It's the solution
Superb
Jun 16 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: martin | last post by:
Hello, I just got the SUN Java IDE. (Netbeans IDE 3.5.1) Very very nice, and I worked myself through the tutorial (about making a colorswitch). Now, When I compile it gives no errors at all. So...
11
by: Svens | last post by:
Hey everyone! I'm a math student working on a short script involving logs. I have a function on my scientific calculator, and was wondering if there was a similar funtion in python. For example:...
4
by: IS | last post by:
At the recommendation of several people in this newsgroup I have downloaded two or three Compilers. One is the Beta version of Microsoft's Visual C++ 2005. I have entered a complete beginner code...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
12
by: uno | last post by:
Hello, I am a beginner with the programming and I have some question. I am reading manuals from Internet and some book from the library. In all those documents the C language operate wint plain...
1
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am...
10
by: Roman Zeilinger | last post by:
Hi I have a beginner question concerning fscanf. First I had a text file which just contained some hex numbers: 0C100012 0C100012 ....
4
by: a | last post by:
Dear all vb.net developer I want to know the time I need to master vb.net? I'm beginner
3
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but...
2
by: roanhn | last post by:
Hello. I've to to write a master's thesis. Currently I deal with php, mysql, ajax. Fate decreed that I've to choose one of this subjects: 1.gdi+ library in .net technology 2.ado.net technology...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.