...

View Full Version : Setting a PHP variable on submission of a form



xupaosso
03-24-2004, 06: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>

Az`
03-24-2004, 06:53 PM
Err... could you just:

if (isset($_POST['name'])) {
$act = 'blah';
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum