HTML Form Post isn’t passing variables to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chvol
Forum Newbie
Posts: 20
Joined: Fri Apr 26, 2002 2:49 pm

HTML Form Post isn’t passing variables to PHP

Post by chvol »

HTML Form Post isn’t passing variables to PHP

Hello all,

I am running Windows 98, PHP Triad Apache 1.3.14 webserver, recently upgraded PHP to 4.0.5 and my forms aren’t passing the variables to PHP anymore.

File php1.php:

<html>
<form action="php2.php" method="post">
<input type=text name="abc">
<input type=submit>
</form>
</html>

File php2.php:

<html>
<?php
echo "[".$abc."]" ;
?>
</html>

Output from connecting to php1.php (after filling in the field and clicking on “Submit Query”):

Warning: Undefined variable: abc in C:\apache\htdocs\php2.php on line 3
[]

Thanks,

Charlie
chvol@aol.com
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

I don't know what PHP triad is, but if it was PHP I would state:

Check your php.ini file. Is register_globals set to On or Off?

I have it Off.
That means I can only (which is very very good) access the post vars by using the form:

$_POST['Varname']

instead, where $_POST is an array containing all posted vars accessible by entering their names as indices.
CONFIQ
Forum Commoner
Posts: 32
Joined: Fri Oct 18, 2002 3:39 pm
Location: Israel - Raanana

Post by CONFIQ »

just wondering... will it work if u put

Code: Select all

extract&#1111;'$_POST'];
It works with extract['$_GET];
User avatar
the_wolf
Forum Newbie
Posts: 2
Joined: Fri Oct 18, 2002 1:29 am
Location: Heidelberg, Germany

Re: HTML Form Post isn&#8217;t passing variables to PHP

Post by the_wolf »

The thing you have to do (and I think this is was Heavy meant) is:

-- PHP1 --

Code: Select all

<?php

echo "<FORM ACTION="php2" METHOD=GET>\n";
echo "<input type "text" NAME="abc" value"some value">\n";
echo "<FORM>\n";

?>
-- PHP 2 --

Code: Select all

<?php

$abc = $_GET&#1111;'abc'];

# if you use another form

echo "<FORM>\n";
echo "<input type "text" NAME="abc" value"$abc">\n";
echo "<FORM>\n";

#if you'd like to just print it out

echo "$abc\n";

?>
GET can normally be used ever but in case of textareas with a large amount of content, for file upload fields or password fields it shouln't. Then just change it to POST.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

CONFIQ:

Code: Select all

extract($_POST);
will work

Code: Select all

extract&#1111;'$_POST'];
won't.

http://www.php.net/manual/en/function.extract.php

Mac
Post Reply