This is a discussion on Simple newbie problem within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, Im a newbie to php and am stuck already at this thing. A page with two input boxes and ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
Im a newbie to php and am stuck already at this thing. A page with two input boxes and then print out what is typed in the box. Using Linux, Apache 1.3.28 and PHP 4.3.3. The url changes to the "test.php?fnamn=Stefan&lname=Fredriksson" but the output is "First name is and last name is ." Any help getting this sorted out would be greatly appriciated. ------------- <html> <head> <title> Test </title> </head> <body> <form> Namn: <input type=text size=10 name=fnamn><br> First Name: <input type=text size=10 name=lname><br><br> <input type=submit value=Go> </form> <?php echo "First name is $fnamn "; echo "and last name is $lname."; ?> </body> </html> ------------- -- Regards Stefan |
|
|||
|
Stefan Fredriksson wrote:
> <?php > echo "First name is $fnamn "; > echo "and last name is $lname."; > ?> > </body> </html> > ------------- hi, since register_globals=Off (php.ini) you have to call the GET variables like this one: <?php echo "First name is ".$_GET["fnamn"]; and so on... ?> additional it helps to declare the method="GET" in your <form> tag ;-) peter |
|
|||
|
Peter Aichhorn wrote:
> Stefan Fredriksson wrote: > >> <?php >> echo "First name is $fnamn "; >> echo "and last name is $lname."; >> ?> >> </body> </html> >> ------------- > > hi, > since register_globals=Off (php.ini) you have to call > the GET variables like this one: > <?php > echo "First name is ".$_GET["fnamn"]; > and so on... > > ?> > > additional it helps to declare the method="GET" in your <form> tag ;-) Thanks for your reply. I did not know about the "register_global" setting. Perhaps this was set to "On" on another machine (windows) I tried a week ago or so. The method you posted is absolutley fine but I still have two further questions. I read that it might be a security problem to set the register_global to "On". Is this the reccomended thing to do even for a not so important (machine will not be connected to internet or another network) machine or is the security problem very minor? The script works without setting method="GET" in the <form> tag and my book says that I don't need to use aditional <form> tags with PHP and that PHP will understand what to do. Should I use it anyway? My script works with both settings. -- Best regards Stefan |
|
|||
|
On Mon, 27 Oct 2003 20:19:14 +0000, Stefan Fredriksson wrote:
--clip-- > The script works without setting method="GET" in the <form> tag and my > book says that I don't need to use aditional <form> tags with PHP and > that PHP will understand what to do. Should I use it anyway? My script > works with both settings. Stating all of the optional stuff (method, action, etc.) may not be needed, but it is certainly good for, and just may save you from having to go back to it in the future. Like using $variable instead of $_GET['variable'], it can work, but if you change the system, any place that you didn't user the $_GET may have to be changed. |