xupaosso
03-24-2004, 05:55 AM
I just need to change the variable $act when the form is submitted. What am I doing wrong?
<html>
<body>
<?
$db='test.mdb';
$conn=new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
if ($act=="change"){
$sql="update TestTable set Customer='$Customer' where CustomerID='1'";
}
else {
$sql='SELECT Customer, CustomerID, PhoneNumber FROM TestTable';
}
$rs=$conn-> Execute($sql);
?>
<table>
<? while (!$rs->EOF){ ?>
<tr>
<td><?= $rs->Fields['Customer']->Value ?></td>
<td><?= $rs->Fields['CustomerID']->Value ?></td>
<td><?= $rs->Fields['PhoneNumber']->Value ?></td>
</tr>
<? $rs->MoveNext() ?>
<? } ?>
</table>
<form name="f" action="blendtecdb.php" method="post">
<input type="hidden" name="act" value="" >
<input type="text" name="name" value="<?=$Customer ?>">
<input type="button" value="Change the Name" onclick="change()">
</form>
<script>
function change(){
document.f.act.value="change";
document.f.submit();
}
</script>
<?
$rs->Close();
$conn->Close();
?>
</body>
</html>
<html>
<body>
<?
$db='test.mdb';
$conn=new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
if ($act=="change"){
$sql="update TestTable set Customer='$Customer' where CustomerID='1'";
}
else {
$sql='SELECT Customer, CustomerID, PhoneNumber FROM TestTable';
}
$rs=$conn-> Execute($sql);
?>
<table>
<? while (!$rs->EOF){ ?>
<tr>
<td><?= $rs->Fields['Customer']->Value ?></td>
<td><?= $rs->Fields['CustomerID']->Value ?></td>
<td><?= $rs->Fields['PhoneNumber']->Value ?></td>
</tr>
<? $rs->MoveNext() ?>
<? } ?>
</table>
<form name="f" action="blendtecdb.php" method="post">
<input type="hidden" name="act" value="" >
<input type="text" name="name" value="<?=$Customer ?>">
<input type="button" value="Change the Name" onclick="change()">
</form>
<script>
function change(){
document.f.act.value="change";
document.f.submit();
}
</script>
<?
$rs->Close();
$conn->Close();
?>
</body>
</html>