You are here: Re: Question from beginner « PHP Programming Language « IT news, forums, messages
Re: Question from beginner

Posted by David Haynes on 12/18/83 11:50

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 ;-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация