Page 1 of 1

HTML Form Post isn’t passing variables to PHP

Posted: Fri Oct 18, 2002 2:48 pm
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

Posted: Fri Oct 18, 2002 3:09 pm
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.

Posted: Fri Oct 18, 2002 3:55 pm
by CONFIQ
just wondering... will it work if u put

Code: Select all

extract&#1111;'$_POST'];
It works with extract['$_GET];

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

Posted: Sat Oct 19, 2002 12:54 am
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.

Posted: Mon Oct 21, 2002 4:48 am
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