themag
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by themag
-
-
Please help – I am having problems using $_POST with PHP5.
My Environment Spec: Win XP SP2, Apache 2.2.3, PHP 5, MySQL 5 (will eventually run on Linux)
I have “register_globals = Off” and “file_uploads = On” in my php.ini
The following simple script works with GET but not with POST:
<?php
if (isset($_POST['submit']))
{
echo "Hi ".$_POST['name']."!<br />";
echo "The address ".$_POST['email']." will soon be a spam-magnet!<br />";
}
?>
<form action="subscribe.php" method="post">
<p>
Name:<br />
<input type="text" name="name" size="20" maxlength="40" value="" />
</p>
<p>
Address:<br />
<input type="text" name="email" size="20" maxlength="40" value="" />
</p>
<input type="submit" name="submit" value="Go!" />
</form>
Does anyone have any ideas what the problem might be? I tried doing some research online but couldn’t find anything.
Any help much appreciated. Cheers,
Problems using $_POST - help needed!
in PHP Coding Help
Posted
Since I am using php5 I updated my php.ini (set register_long_arrays = On) to allow the use of $HTTP_POST_VARS. Unfortunately this just produced the following output when I post: Array ( )
i.e. there doesn't seem to be any data being POSTed.....
With regards to the php script above I tried this but got the following errors:
"Notice: Undefined index: submit in C:\Apache2.2\htdocs\subscribe2.php on line 3"
"Notice: Undefined variable: PHP_SELF in C:\Apache2.2\htdocs\subscribe2.php on line 13"
So I changed the code to this:
[code]
<?php
if (isset($_POST['submit']))
{
$test = $_POST['butt'];
echo"$test";
}
$script = $_SERVER['PHP_SELF'];
echo"
<table align=\"center\">
<form method=\"post\" action=\"$script\">
<tr><td>Text to test: </td><td><input type=\"text\" name=\"butt\"></td></tr>
<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Do It!\"></td></tr>
</form>
</table>";
?>
[/code]
This didn't display any value on the screen when I filled in the form with values and hit submit.....
Could it be an apache setting or something else in my php.ini?
Thanks
Could be an apache setting or something else in my php.ini?