HTML Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kathy

    HTML Form

    Can someone help me with the code to take the data in four fields on an HTML
    form and add it to a table in a database on an intranet.

    Thanks to all who help!

    Kathy


  • Jerry Boone

    #2
    Re: HTML Form

    Kathy,

    You need file based access to the database from your Intranet server. From
    there you will create two
    pages, one that holds the form and fields, the second that holds the code to
    connect to your mdb. Then execute an "INSERT" sql statement to get the data
    into a table. If you are not familiar with any of that, you should look
    into the ADO connection object. It would accomplish all of this easily if
    you can use ASP or vbscript on the second page. It is important to keep in
    mind that the code written on the second page runs only on the server and is
    never shown to the user by means of using special tags that specify to
    "runat" the server.

    If you are running IIS on your intranet server then this is the vbscript for
    Microsoft ASP pages...

    First page: (firstpage.asp)
    <html>
    <body>
    <p>Please fill in this data....</p>
    <form name="myform" method="post" action="secondp age.asp">
    <input name="fldFirstN ame" Value="">
    <input name="fldLastNa me" Value="">
    </form>
    </body>
    </html>

    Second page: (secondpage.asp )
    <%
    dim cn
    Set cnn1 = Server.CreateOb ject("ADODB.Con nection")
    cnn1.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
    Server.MapPath( "/somesubfolder/somedb.mdb") & ";Persist Security Info=False"
    cnn1.execute "INSERT Into myTable FirstName, LastName VALUES(" &
    request.form("f ldFirstName") & ", " & request.form("f ldLastName") & ")"
    cnn.close
    set cnn = nothing
    response.write "<html><body><p >Thanks for adding that
    data...</p></body></html>"
    %>

    You can replace the Server.MapPath( ) with the actual path to the mdb. The
    tools are all there, it's just
    a matter of learning! Let me know if you need any more help with that.

    Good Luck!!

    Jerry Boone
    jerry@antech.bi z.nospam (remove .nospam before sending)
    President - Analytical Technologies, Inc.
    ASP, ASP.NET, SQL Server Hosting




    "Kathy" <kdesaint@earth link.net> wrote in message
    news:a_czb.1885 $Oe5.1436@newsr ead2.news.atl.e arthlink.net...[color=blue]
    > Can someone help me with the code to take the data in four fields on an[/color]
    HTML[color=blue]
    > form and add it to a table in a database on an intranet.
    >
    > Thanks to all who help!
    >
    > Kathy
    >
    >[/color]


    Comment

    • Kathy

      #3
      Re: HTML Form

      Jerry,

      Thank you very much for the response!!

      I normally see a Submit button on a form like this but I don't see one here.
      What causes the code on the second page to execute after the user fills in the
      fields on the first page?

      Can this be done with DAO and without ASP?

      Thanks!

      Kathy




      "Jerry Boone" <jerry@antech.b iz.killspam> wrote in message
      news:MOpzb.192$ t56.74194076@ne wssvr11.news.pr odigy.com...[color=blue]
      > Kathy,
      >
      > You need file based access to the database from your Intranet server. From
      > there you will create two
      > pages, one that holds the form and fields, the second that holds the code to
      > connect to your mdb. Then execute an "INSERT" sql statement to get the data
      > into a table. If you are not familiar with any of that, you should look
      > into the ADO connection object. It would accomplish all of this easily if
      > you can use ASP or vbscript on the second page. It is important to keep in
      > mind that the code written on the second page runs only on the server and is
      > never shown to the user by means of using special tags that specify to
      > "runat" the server.
      >
      > If you are running IIS on your intranet server then this is the vbscript for
      > Microsoft ASP pages...
      >
      > First page: (firstpage.asp)
      > <html>
      > <body>
      > <p>Please fill in this data....</p>
      > <form name="myform" method="post" action="secondp age.asp">
      > <input name="fldFirstN ame" Value="">
      > <input name="fldLastNa me" Value="">
      > </form>
      > </body>
      > </html>
      >
      > Second page: (secondpage.asp )
      > <%
      > dim cn
      > Set cnn1 = Server.CreateOb ject("ADODB.Con nection")
      > cnn1.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
      > Server.MapPath( "/somesubfolder/somedb.mdb") & ";Persist Security Info=False"
      > cnn1.execute "INSERT Into myTable FirstName, LastName VALUES(" &
      > request.form("f ldFirstName") & ", " & request.form("f ldLastName") & ")"
      > cnn.close
      > set cnn = nothing
      > response.write "<html><body><p >Thanks for adding that
      > data...</p></body></html>"
      > %>
      >
      > You can replace the Server.MapPath( ) with the actual path to the mdb. The
      > tools are all there, it's just
      > a matter of learning! Let me know if you need any more help with that.
      >
      > Good Luck!!
      >
      > Jerry Boone
      > jerry@antech.bi z.nospam (remove .nospam before sending)
      > President - Analytical Technologies, Inc.
      > ASP, ASP.NET, SQL Server Hosting
      > http://www.antech.biz
      >
      >
      >
      > "Kathy" <kdesaint@earth link.net> wrote in message
      > news:a_czb.1885 $Oe5.1436@newsr ead2.news.atl.e arthlink.net...[color=green]
      > > Can someone help me with the code to take the data in four fields on an[/color]
      > HTML[color=green]
      > > form and add it to a table in a database on an intranet.
      > >
      > > Thanks to all who help!
      > >
      > > Kathy
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Jerry Boone

        #4
        Re: HTML Form

        Sure, you can drop a submit button on and that will be fine. Anything that
        submits the <form> will post the data to the server. The Action element in
        the <form> tags tells the page to submit TO secondpage.asp. When
        secondpage.asp is being loaded, it reads in the form elements and their
        values, then pokes them into the database by using
        request.field(" somefieldname") .

        I only work with ASP so I don't know about using something else. ASP is
        enabled on every version of Windows... Win98 (by use of Personal Web
        Server), NT4 Workstation (by use of Personal Web Server from resource kit),
        NT4 Server (IIS3,4,5), Win2K(IIS 5,6), and XP Pro (IIS6). Once you do that,
        you can access your intranet by using http://myservername/sompage.asp (or
        html). It's really easy.

        You should be able to use DAO components for data transfer, but your on your
        own there. ADO is my first choice because it's heavily documented, has
        multiple ways to do things, and by nature is designed for this task. It
        also contains way more features for other operations, including xml and
        offline file based recordsets that are portable and can be re-instantiated
        for use. Too much to list on that stuff, books are written just to cover
        these components....

        :)

        --
        Jerry Boone
        Analytical Technologies, Inc.



        "Kathy" <kdesaint@earth link.net> wrote in message
        news:_Wqzb.2696 $Qd6.1210@newsr ead1.news.atl.e arthlink.net...[color=blue]
        > Jerry,
        >
        > Thank you very much for the response!!
        >
        > I normally see a Submit button on a form like this but I don't see one[/color]
        here.[color=blue]
        > What causes the code on the second page to execute after the user fills in[/color]
        the[color=blue]
        > fields on the first page?
        >
        > Can this be done with DAO and without ASP?
        >
        > Thanks!
        >
        > Kathy
        >
        >
        >
        >
        > "Jerry Boone" <jerry@antech.b iz.killspam> wrote in message
        > news:MOpzb.192$ t56.74194076@ne wssvr11.news.pr odigy.com...[color=green]
        > > Kathy,
        > >
        > > You need file based access to the database from your Intranet server.[/color][/color]
        From[color=blue][color=green]
        > > there you will create two
        > > pages, one that holds the form and fields, the second that holds the[/color][/color]
        code to[color=blue][color=green]
        > > connect to your mdb. Then execute an "INSERT" sql statement to get the[/color][/color]
        data[color=blue][color=green]
        > > into a table. If you are not familiar with any of that, you should look
        > > into the ADO connection object. It would accomplish all of this easily[/color][/color]
        if[color=blue][color=green]
        > > you can use ASP or vbscript on the second page. It is important to keep[/color][/color]
        in[color=blue][color=green]
        > > mind that the code written on the second page runs only on the server[/color][/color]
        and is[color=blue][color=green]
        > > never shown to the user by means of using special tags that specify to
        > > "runat" the server.
        > >
        > > If you are running IIS on your intranet server then this is the vbscript[/color][/color]
        for[color=blue][color=green]
        > > Microsoft ASP pages...
        > >
        > > First page: (firstpage.asp)
        > > <html>
        > > <body>
        > > <p>Please fill in this data....</p>
        > > <form name="myform" method="post" action="secondp age.asp">
        > > <input name="fldFirstN ame" Value="">
        > > <input name="fldLastNa me" Value="">
        > > </form>
        > > </body>
        > > </html>
        > >
        > > Second page: (secondpage.asp )
        > > <%
        > > dim cn
        > > Set cnn1 = Server.CreateOb ject("ADODB.Con nection")
        > > cnn1.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
        > > Server.MapPath( "/somesubfolder/somedb.mdb") & ";Persist Security[/color][/color]
        Info=False"[color=blue][color=green]
        > > cnn1.execute "INSERT Into myTable FirstName, LastName VALUES(" &
        > > request.form("f ldFirstName") & ", " & request.form("f ldLastName") & ")"
        > > cnn.close
        > > set cnn = nothing
        > > response.write "<html><body><p >Thanks for adding that
        > > data...</p></body></html>"
        > > %>
        > >
        > > You can replace the Server.MapPath( ) with the actual path to the mdb.[/color][/color]
        The[color=blue][color=green]
        > > tools are all there, it's just
        > > a matter of learning! Let me know if you need any more help with that.
        > >
        > > Good Luck!!
        > >
        > > Jerry Boone
        > > jerry@antech.bi z.nospam (remove .nospam before sending)
        > > President - Analytical Technologies, Inc.
        > > ASP, ASP.NET, SQL Server Hosting
        > > http://www.antech.biz
        > >
        > >
        > >
        > > "Kathy" <kdesaint@earth link.net> wrote in message
        > > news:a_czb.1885 $Oe5.1436@newsr ead2.news.atl.e arthlink.net...[color=darkred]
        > > > Can someone help me with the code to take the data in four fields on[/color][/color][/color]
        an[color=blue][color=green]
        > > HTML[color=darkred]
        > > > form and add it to a table in a database on an intranet.
        > > >
        > > > Thanks to all who help!
        > > >
        > > > Kathy
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...