Code: Select all
if (count($_POST)>0) {
foreach($_POST as $key => $value)}The following produces an output of the posted values:
Code: Select all
{
echo $key, ": ", $value, "<br>";
}Moderator: General Moderators
Code: Select all
if (count($_POST)>0) {
foreach($_POST as $key => $value)}Code: Select all
{
echo $key, ": ", $value, "<br>";
}Code: Select all
$tmp_VariableName = $_POST['FormVariableName'];Meaning: you've showed us the the part of your script that is working but not the part that is not working. What are we supposed to say?Taras wrote:However, when I try to manipulate the variables I find that they have no values assigned to them.
Code: Select all
<form method="POST" action = "test.php">
<input type="text" size="10" name="year1">
<input type="text" size="10" name="month1">
<input type="text" size="10" name="day1">
<p><input type="submit" name="Sumbmit" value="Submit"></p>Code: Select all
echo $year1."-".$month."-".$day;Code: Select all
$year1 = $_POST["year1"];
$month1 = $_POST["month1"];
$day1 = $_POST["day1"];either typo or missing 1 after $month and $day.Taras wrote:echo $year1."-".$month."-".$day;
Code: Select all
<html>
<head><title>...</title></head>
<body>
<pre><?php print_r($_POST); ?></pre>
<?php
if ( isset($_POST["year1"], $_POST["month1"], $_POST["day1"]) ) {
echo $_POST["year1"], '-', $_POST["month1"], '-', $_POST["day1"];
$day1 = $_POST["day1"] + 5;
echo ' ', $day1;
}
?>
<form method="POST" action="?">
<div>
<input type="text" size="10" name="year1">
<input type="text" size="10" name="month1">
<input type="text" size="10" name="day1">
<br />
<input type="submit" name="Sumbmit" value="Submit">
</div>
</form>
</body>
</html>Code: Select all
echo $year1."-".$month1."-".$day1;Code: Select all
if (count($_POST)>0) {
foreach($_POST as $key => $value)}Code: Select all
<html>
<head><title>...</title></head>
<body>
<?php
$t = '';
$s = 0;
foreach($_POST as $key=>$value) {
$t .= $key;
$s += $value;
}
echo $t, ' # ', $s, "<br />";
?>
<form method="POST" action="?">
<div>
<input type="text" size="10" name="year1">
<input type="text" size="10" name="month1">
<input type="text" size="10" name="day1">
<br />
<input type="submit" name="Submit" value="Submit">
</div>
</form>
</body>
</html>Code: Select all
foreach($_POST as $key => $value)
{
$$key = $value;
}Code: Select all
foreach($_POST as $key=>$value) {
$t .= $key;
$s += $value;
}No it uses the already existing variables/elements to do some..thing (useless, it's only an example).Taras wrote:volka, would your methodturn the keys into variables?Code: Select all
foreach($_POST as $key=>$value) { $t .= $key; $s += $value; }