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

Beginners problem

P: n/a
Hi,

I'm just beginning PHP programming. I have installed Apache 2.0.48 and
PHP 4.3.3. The installation went well. Then I was trying a little example.

HTML page:

<html>
<head>
<title>test</title>
</head>

<body>

<form action="test.php" method=POST>
First Name: <input type=text name=firstname size=30
MAXLENGTH=150>
<input type=submit value="Send">
</form>

</body>
</html>

and the PHP script "test.php":

<?php
echo "First Name = ";
echo $firstname;
echo ".";
?>

When I insert "Rolf" into the textfield and hit the "Send" button I get
the response:

First Name = .

Nothing else. I thought that the variable $firstname is set to the
string I inserted into the text field. Did I do anything wrong or could
there be a problem with apache or php? I would be very appreciative for
help on this problem.

Regards

Rolf Wester

P.S.: When using method GET the form calls:
http://localhost:8080/test.php?firstname=Rolf
The Response is the same as before.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Rolf Wester wrote:
Hi,

I'm just beginning PHP programming. I have installed Apache 2.0.48 and
PHP 4.3.3. The installation went well. Then I was trying a little example.

HTML page:

<html>
<head>
<title>test</title>
</head>

<body>

<form action="test.php" method=POST>
First Name: <input type=text name=firstname size=30
MAXLENGTH=150>
<input type=submit value="Send">
</form>

</body>
</html>

and the PHP script "test.php":

<?php
echo "First Name = ";
echo $firstname;
echo ".";
?>

When I insert "Rolf" into the textfield and hit the "Send" button I get
the response:

First Name = .

Nothing else. I thought that the variable $firstname is set to the
string I inserted into the text field. Did I do anything wrong or could
there be a problem with apache or php? I would be very appreciative for
help on this problem.

Regards

Rolf Wester

P.S.: When using method GET the form calls:
http://localhost:8080/test.php?firstname=Rolf
The Response is the same as before.


Very common problem this. You have register_globals turned off, it's the
default in recent releases of php.

replace
echo $firstname;
with
echo $_POST['firstname'];
and all will be well

Jul 17 '05 #2

P: n/a
On Fri, 31 Oct 2003 17:53:45 +0100
Rolf Wester <we****@ilt.fraunhofer.de> wrote:
Hi,

I'm just beginning PHP programming. I have installed Apache 2.0.48 and
PHP 4.3.3. The installation went well. Then I was trying a little example.

HTML page:

<html>
<head>
<title>test</title>
</head>

<body>

<form action="test.php" method=POST>
First Name: <input type=text name=firstname size=30
MAXLENGTH=150>
<input type=submit value="Send">
</form>

</body>
</html>

and the PHP script "test.php":

<?php
echo "First Name = ";
echo $firstname;
echo ".";
?> /////////////////////////////////////////////////////////
in php.ini register_globals = On or use $HTTP_POST_VARS["firstname"]
////////////////////////////////////////////////////////

When I insert "Rolf" into the textfield and hit the "Send" button I get
the response:

First Name = .

Nothing else. I thought that the variable $firstname is set to the
string I inserted into the text field. Did I do anything wrong or could
there be a problem with apache or php? I would be very appreciative for
help on this problem.

Regards

Rolf Wester

P.S.: When using method GET the form calls:
http://localhost:8080/test.php?firstname=Rolf
The Response is the same as before.

Jul 17 '05 #3

P: n/a
Kevin Thorpe wrote:

Very common problem this. You have register_globals turned off, it's the
default in recent releases of php.

replace
echo $firstname;
with
echo $_POST['firstname'];
and all will be well

Thanks a lot. It works now. Is it possible to turn register_globals on
and if so how can I do it?

Regards

Rolf Wester

Jul 17 '05 #4

P: n/a
<sa***@fan.astral.ntu-kpi.kiev.ua> wrote in message
news:20031031190557.11a9cf70.sa***@fan.astral.ntu-kpi.kiev.ua...
On Fri, 31 Oct 2003 17:53:45 +0100
Rolf Wester <we****@ilt.fraunhofer.de> wrote:
Hi,

I'm just beginning PHP programming. I have installed Apache 2.0.48 and
PHP 4.3.3. The installation went well. Then I was trying a little example.
HTML page:

<html>
<head>
<title>test</title>
</head>

<body>

<form action="test.php" method=POST>
First Name: <input type=text name=firstname size=30
MAXLENGTH=150>
<input type=submit value="Send">
</form>

</body>
</html>

and the PHP script "test.php":

<?php
echo "First Name = ";
echo $firstname;
echo ".";
?>

/////////////////////////////////////////////////////////
in php.ini register_globals = On or use $HTTP_POST_VARS["firstname"]
////////////////////////////////////////////////////////

When I insert "Rolf" into the textfield and hit the "Send" button I get
the response:

First Name = .

Nothing else. I thought that the variable $firstname is set to the
string I inserted into the text field. Did I do anything wrong or could
there be a problem with apache or php? I would be very appreciative for
help on this problem.

Regards

Rolf Wester

P.S.: When using method GET the form calls:
http://localhost:8080/test.php?firstname=Rolf
The Response is the same as before.


I wouldn't do that if I were you.
It's best to get into good habits from the start.
Globals on is a security risk.

Regards
Richard Grove

http://redeyemedia.co.uk
http://shopbuilder.org
Become a Shop Builder re-seller:
http://affiliatewindow.com/affiliate...ls.php?mid=611
Jul 17 '05 #5

P: n/a
Hi,

thanks to all for your help. I would like to turn on register_globals
mainly for the purpose of trying some sample-scripts downloaded from
somewhere that rely on this. I will use the more secure option
$_POST['**'] for my own scripts.

Regards

Rolf Wester

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.