Is it possible to click on a button, and not have it's value and name stored
in _POST?
I have this script with a button on it. When you click the button, the page
posts to itself. The first time you click this Save Changes button, _POST
is empty. After clicking the button, and the page is loaded again, if you
click Save Changes once more the _POST is properly set. What's up with
that?
$studentCode; // Will hold the current student code, if applicable
....
foreach(array_k eys($_POST) as $key)
{
$$key = $_POST[$key];
print "$key is ${$key}<br />";
echo "It is: " . $_POST["Submit"] . "<br>";
}
if ($_POST["Submit"] == "Add Student") // Save button was hit
addRecord();
elseif ($_POST["Submit"] == "Save Changes") // Save changes button was hit
updateStudent() ;
echo "We're saving changes<br>";
elseif ($_GET["action"] != "add")
getOldData($rec ord);
echo "<table summary=\"\" cellpadding=\"5 \">";
function printLabelCell( )
{
echo "\n<tr><td align=\"right\" >";
}
if (isset($_GET["studentCod e"]))
$studentCode = $_GET["studentCod e"];
elseif (isset($_POST["studentCod e"]))
$studentCode = $_POST["studentCod e"];
if ($studentCode != "")
$postType = "post?studentCo de=" . $studentCode;
else
$postType = "post";
echo '<form action="addEdit Student.php" method="' . $postType . '">';
// ... print controls in the cells ...
echo "<tr><td colspan=\"2\" align=\"center\ ">";
echo '<br>';
if ($_GET["action"] == "add" or isset($_POST["firstName"]))
echo '<input type="Submit" name="Submit" value="Add Student">
';
else
echo '<input type="Submit" name="Submit" value="Save Changes">';
echo ' <input type="Reset" name="Reset" value="Clear
Data"><br><br>' ;
echo "</td></tr></table>";
echo "</form>";
function DisplayTextbox( $vname, $size, $value)
{
echo "</td><td><Input type=\"text\" name = \"" . $vname . "\" Size = \""
.. $size . "\" value=\"" . $value . "\"></td></tr>";
}
mysql_close($li nk);
....
<Ade
--
Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
"A society that views graphic violence as entertainment ...should not be
surprised when senseless violence shatters the dreams of it's youngest and
brightest..." - Ensign (March 2004)
in _POST?
I have this script with a button on it. When you click the button, the page
posts to itself. The first time you click this Save Changes button, _POST
is empty. After clicking the button, and the page is loaded again, if you
click Save Changes once more the _POST is properly set. What's up with
that?
$studentCode; // Will hold the current student code, if applicable
....
foreach(array_k eys($_POST) as $key)
{
$$key = $_POST[$key];
print "$key is ${$key}<br />";
echo "It is: " . $_POST["Submit"] . "<br>";
}
if ($_POST["Submit"] == "Add Student") // Save button was hit
addRecord();
elseif ($_POST["Submit"] == "Save Changes") // Save changes button was hit
updateStudent() ;
echo "We're saving changes<br>";
elseif ($_GET["action"] != "add")
getOldData($rec ord);
echo "<table summary=\"\" cellpadding=\"5 \">";
function printLabelCell( )
{
echo "\n<tr><td align=\"right\" >";
}
if (isset($_GET["studentCod e"]))
$studentCode = $_GET["studentCod e"];
elseif (isset($_POST["studentCod e"]))
$studentCode = $_POST["studentCod e"];
if ($studentCode != "")
$postType = "post?studentCo de=" . $studentCode;
else
$postType = "post";
echo '<form action="addEdit Student.php" method="' . $postType . '">';
// ... print controls in the cells ...
echo "<tr><td colspan=\"2\" align=\"center\ ">";
echo '<br>';
if ($_GET["action"] == "add" or isset($_POST["firstName"]))
echo '<input type="Submit" name="Submit" value="Add Student">
';
else
echo '<input type="Submit" name="Submit" value="Save Changes">';
echo ' <input type="Reset" name="Reset" value="Clear
Data"><br><br>' ;
echo "</td></tr></table>";
echo "</form>";
function DisplayTextbox( $vname, $size, $value)
{
echo "</td><td><Input type=\"text\" name = \"" . $vname . "\" Size = \""
.. $size . "\" value=\"" . $value . "\"></td></tr>";
}
mysql_close($li nk);
....
<Ade
--
Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
"A society that views graphic violence as entertainment ...should not be
surprised when senseless violence shatters the dreams of it's youngest and
brightest..." - Ensign (March 2004)
Comment