I have a form setup inside my php script that holds dynamic information being stored in a ms access database. I would like to update that database upon the user clicking the submit button. I have my insert statements and everything written the way I want it to preform. But I how do I include certain form varibles into my insert statement. And where would I put the code to execute the statement after the button is pressed...

I see that I need to brush up on html any tutorials or links available?

Thanks in advance.......

    You know HTML forms have an action target: <form name="something" action="page.php" method="post">

    So, in page.php you should include the database interaction code.

    To retrieve a form variable, simply call it $variable or $POST[variable] ($GET[variable] if you've set method="get")

      You can submit your form in two ways: to itself or another page

      // submit the form to the same page
      <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
      // or submit the form to a different page
      <form action="formHandler.php" method="post">
      

      Either way you will handle the past vars that same way, assuming you are using post. Your query...

      $passVar1 = $_POST['var1'];
      $passVar2 = $_POST['var2'];
      // as many vars as needed
      INSERT INTO table ( field1, field2, ... ) VALUES ( $passVar1, $passVar2, ... );
      

      I hope that helps,
      phpmoron

        Hi,

        You have a form, in the form of:

        <form method="post" action="SomePagephp">
        <input type="" name="SomeName">
        <input type="submit">
        </form>

        Then, in SomePage.php you place the insert commands. You can directly use $SomeName as input value.

        Hope this helps.

        J.

          it says that the variables are undefined... ???

            Write a Reply...