Simple newbie problem

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-27-2003
Stefan Fredriksson
 
Posts: n/a
Default Simple newbie problem

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

Reply With Quote
  #2 (permalink)  
Old 10-27-2003
Peter Aichhorn
 
Posts: n/a
Default Re: Simple newbie problem

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


Reply With Quote
  #3 (permalink)  
Old 10-27-2003
Stefan Fredriksson
 
Posts: n/a
Default Re: Simple newbie problem

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

Reply With Quote
  #4 (permalink)  
Old 10-28-2003
Charles Collins
 
Posts: n/a
Default Re: Simple newbie problem

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:45 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0