Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting a PHP variable on submission of a form

    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>
    Help! I've reached the end of my code!

  • #2
    Az`
    Az` is offline
    New Coder
    Join Date
    Mar 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Err... could you just:
    PHP Code:
    if (isset($_POST['name'])) {
    $act 'blah';



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •