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 3 of 3

Thread: Form to Datbase

  1. #1
    Regular Coder saeed's Avatar
    Join Date
    Oct 2002
    Location
    West Yorkshire
    Posts
    343
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Form to Datbase

    html file.
    Code:
    <html>
    <head>
    <title></title>
    </head>
    
    <body>
    
    <p align="center"><b><font face="Verdana">Data Entry Form</font></b></p>
    <form method="post" action="add_to_database.asp">
    <table border="0" width="70%" id="table1">
        <tr>
            <td width="118" align="left" valign="top"><font face="Verdana" size="2">Name:</font></td>
            <td><input type="text" name="name" size="30"></td>
        </tr>
        <tr>
            <td width="118" align="left" valign="top"><font face="Verdana" size="2">Email:</font></td>
            <td><input type="text" name="email" size="30"></td>
        </tr>
        <tr>
            <td width="118" align="left" valign="top"><font face="Verdana" size="2">Comment:</font></td>
            <td><textarea rows="9" name="comments" cols="25"></textarea></td>
        </tr>
        <tr>
            <td width="118">&nbsp;</td>
            <td><input type="button" value="Add" name="bt_add">
            <input type="button" value="Edit" name="bt_Edit">
            <input type="submit" value="Save" name="bt_Save">
            <input type="button" value="Delete" name="bt_Delete">
            <input type="button" value="Update" name="bt_Update">
            </td>
        </tr>
        <tr>
            <td width="118">&nbsp;</td>
            <td><input type="button" value="&lt;&lt; First" name="bt_First">
            <input type="button" value="&lt; Previous" name="bt_Previous">
            <input type="button" value="Next &gt;" name="bt_Next">
            <input type="button" value="Last &gt;&gt;" name="bt_Last">
            <p><a href="javascript:window.close()">Exit the System</a></p>
            </td>
        </tr>
    </table>
    </form>
    </body>
    
    </html>
    asp file

    Code:
    <%@ Language="VBScript" %>
    <% Option Explicit %>
    <html>
    <head>
    <title>Form to database</title>
    </head>
    <body>
    <%
    'declare your variables
    Dim name, email, comments
    Dim sConnString, connection, sSQL
    'Receiving values from Form, assign the values entered to variables
    name = Request.Form("name")
    email = Request.Form("email")
    comments =Request.Form("comments")
    
    'declare SQL statement that will query the database
    sSQL = "INSERT into users_tbl (name, email, comments) values ('" & _
    name & "', '" & email & "', '" & comments & "')"
    'define the connection string, specify database
    'driver and the location of database
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("Users.mdb")
    'create an ADO connection object
    Set connection = Server.CreateObject("ADODB.Connection")
    
    'Open the connection to the database
    connection.Open(sConnString)
    
    'execute the SQL
    connection.execute(sSQL)
    
    response.write "Comments are saved successfully."
    'Done. Close the connection object
    connection.Close
    Set connection = Nothing
    %>
    </body>
    </html>
    can someone help me with displaying records.. I want records displaying through Previous Next First and Last button.

    thanks,


    saeed.
    Don't click on this!

    #!/usr/bin/saeed

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    If you want previous and next buttons, I'd start by reading a few tutorials on paging in ASP.

  • #3
    Regular Coder saeed's Avatar
    Join Date
    Oct 2002
    Location
    West Yorkshire
    Posts
    343
    Thanks
    32
    Thanked 0 Times in 0 Posts
    thanks man

    appreciated!
    Don't click on this!

    #!/usr/bin/saeed


  •  

    Posting Permissions

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