A
Anonymous
Guest
and in other books (SAMS) WROX etc and php.net
This is sooo annoying ...... what is wrong....
a simple submit form with hidden fields as below at code sample 1, fields are identified with id and name parameters
the resultscript.php code is shown in code sample 2, some simple tracing and a foreach (http_post_vars)
Problem
this is the really stupid bit;
when I execute the form (no problems) it goes to the resultspage (no problems) but the
print "$varname == $value" statement prints as follows
value == value
value == value
etc
and not
varname == value
varname == value
etc
as expected
with the result that the rest of the form obviously does not work correctly. The number of results is correct. but not the variables....
Why does the foreach loop not assign the (local) variables the name with its associated value.
This is killing me - time for tea and a kebab I think.............
Thanks in advance
regards
Sean
Code Sample 1
Code Sample 2
[/code]
This is sooo annoying ...... what is wrong....
a simple submit form with hidden fields as below at code sample 1, fields are identified with id and name parameters
the resultscript.php code is shown in code sample 2, some simple tracing and a foreach (http_post_vars)
Problem
this is the really stupid bit;
when I execute the form (no problems) it goes to the resultspage (no problems) but the
print "$varname == $value" statement prints as follows
value == value
value == value
etc
and not
varname == value
varname == value
etc
as expected
with the result that the rest of the form obviously does not work correctly. The number of results is correct. but not the variables....
Why does the foreach loop not assign the (local) variables the name with its associated value.
This is killing me - time for tea and a kebab I think.............
Thanks in advance
regards
Sean
Code Sample 1
Code:
<html>
<head>
<title>test001</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="resultscript.php" method="post">
<input type="hidden" id="transactionstatus" name="transactionstatus" value="1">
<input type="hidden" id="total" name="total" value="2">
<input type="hidden" id="clientid" name="clientid" value="3">
<input type="hidden" id="oid" name="oid" value="4">
<input type="submit" id="button" name="Test" value="Test">
</form>
</body>
</html>
Code Sample 2
Code:
<?php
echo "step point 0\n<br>";
foreach ($HTTP_POST_VARS as $varname => $value)
{
$varname = stripslashes($value);
print "$varname == $value<br>";
}
if (strcmp(getenv("REQUEST_METHOD"),"post"))
{
echo "step point 1\n<br>";
$msgText = "$oid - Transaction Status - $transactionstatus\n";
$msgText = $msgText."$oid - Transaction Total - $total\n";
$msgText = $msgText."$oid - Transaction Client - $clientid\n";
$msgText = $msgText."$oid - Transaction OID - $oid\n";
mail( "zzz@123", "New booking Result", $msgText, "From: zzz@123" );
echo "step point 2\n<br>";
}
else
{
echo "step point 3\n<br>";
mail( "zzz@123", "New booking Result", "Unsuccessful Post 1", "From: zzz@123" );
echo "step point 4\n<br>";
}
echo "step point 5\n<br>";
?>