468,248 Members | 1,464 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

php4.3.2 can't get POST to work.

Hello,

I've installed php4.3.2 on my Redhat 8.0 box along with Apache2.046.
I'm trying to teach myself some php using Larry Ullman's book "PHP for
the World Wide Web".

There's one example I typed just as it appears in the book but it
dosen't work. I was wondering if there was some setting that needs to
be set in the php config for it to work.

The script is a simple html script, which calls a php script passing
it the variables which it got by the forms:

#########HTML SCRIPT###################
<html>
<head>
<title>HTML Form</title>
</head>
<body>
<form ACTION="HandleForm.php" METHOD=POST>
First Name<input TYPE=TEXT NAME="FirstName" SIZE=20><br>
Last Name <input TYPE=TEXT NAME="LastName" SIZE=20><br>
E-mail Address <input TYPE=TEXT NAME="Email" SIZE=60><br>
Comments <textarea NAME="Comments" ROWS=5 COLS=40></textarea><br>
<input TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</form>

</body>
</html>

##############PHP SCRIPT "HandleForm.php"#####################
<HTML>
<HEAD>
<TITLE>Form Results</title>
<BODY>
<?php
/* This page receives and handles the data generated by "form.html".
*/
print "Your first name is $FirstName.<BR>\n";
print "Your last name is $LastName.<BR>\n";
print "Your E-mail is $Email.<BR>\n";
print "This is what you had to say:<BR>\n$Comments<BR>\n";
?>
</BODY>
</HTML>

####
This is the output:
Your first name is .
Your last name is .
Your E-mail is .
This is what you had to say:
All the variables are apparently empty. I've also tried with the GET
method. Any idea of what could be wrong in either my script or php
settings ?

Acteon
Jul 16 '05 #1
2 3421
As the other fellow said, do a search for register_globals.

Try using $_POST["myvariable"] and $_GET["myvariable"] to read from
variables, instead of $myvariable. (where myvariable is the name of an
object in the submitted form).

"Acteon" <ac****@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
Hello,

I've installed php4.3.2 on my Redhat 8.0 box along with Apache2.046.
I'm trying to teach myself some php using Larry Ullman's book "PHP for
the World Wide Web".

There's one example I typed just as it appears in the book but it
dosen't work. I was wondering if there was some setting that needs to
be set in the php config for it to work.

The script is a simple html script, which calls a php script passing
it the variables which it got by the forms:

#########HTML SCRIPT###################
<html>
<head>
<title>HTML Form</title>
</head>
<body>
<form ACTION="HandleForm.php" METHOD=POST>
First Name<input TYPE=TEXT NAME="FirstName" SIZE=20><br>
Last Name <input TYPE=TEXT NAME="LastName" SIZE=20><br>
E-mail Address <input TYPE=TEXT NAME="Email" SIZE=60><br>
Comments <textarea NAME="Comments" ROWS=5 COLS=40></textarea><br>
<input TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</form>

</body>
</html>

##############PHP SCRIPT "HandleForm.php"#####################
<HTML>
<HEAD>
<TITLE>Form Results</title>
<BODY>
<?php
/* This page receives and handles the data generated by "form.html".
*/
print "Your first name is $FirstName.<BR>\n";
print "Your first name is $_POST["FirstName"].<BR>\n";
print "Your last name is $LastName.<BR>\n";
print "Your last name is $_POST["LastName"].<BR>\n";
print "Your E-mail is $Email.<BR>\n";
print "Your E-mail is $_POST["Email"].<BR>\n";
print "This is what you had to say:<BR>\n$Comments<BR>\n";
print "This is what you had to say:<BR>\n$_POST["Comments"]<BR>\n";
?>
</BODY>
</HTML>

####
This is the output:
Your first name is .
Your last name is .
Your E-mail is .
This is what you had to say:
All the variables are apparently empty. I've also tried with the GET
method. Any idea of what could be wrong in either my script or php
settings ?

Acteon

Jul 16 '05 #2
"Richard Hockey" <ri***********@dsl.pipex.com> wrote in message news:<3f***********************@news.dial.pipex.co m>...
As the other fellow said, do a search for register_globals.

Try using $_POST["myvariable"] and $_GET["myvariable"] to read from
variables, instead of $myvariable. (where myvariable is the name of an
object in the submitted form).


Thank you, that solved the problem. I ended up declaring my variables
on top:

$FirstName = $_POST["FirstName"];
$LastName = $_POST["LastName"];

and so on.

This way If I need to use the variable more then once I won't need to
keep typing $_POST["varname"]. Is that how php coders usually do it ?
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Ziaran _ | last post: by
1 post views Thread by NagaKiran | last post: by
2 posts views Thread by mc | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.