Login | |
|
 |
ASP database access - 5/1/2005 12:37:30 AM
|
|
 |
|
| |
greentea
Posts: 3
Score: 0
Joined: 4/30/2005
From: United Kingdom
Status: offline
|
Hi All, I am trying to write an ASP adds a user's details to a database, returns an ID called 'CustID'. At the moment CustID is returned in an alert box, which is a complete no no. I'm wondering if anyone can give me some guidance as to how to return the CustID and place it in a text input box on a form. The form is contained in the page 'index.html', the code for the ASP and the HTML page is below. Thanks in advance for anyone who takes the time. <html> <head><title>AddCustomer asp file</title></head> <body bgcolor=#ffffff text = #000000> <font color = "red">Redirecting to login page</font> <% dim conn, dbPath, dbConnect, SQL, RS dbPath = Server.MapPath("Databases/project.mdb") dbConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & dbPath Set conn = Server.CreateObject("ADODB.Connection") conn.Open dbConnect Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "Customers", conn, 1, 3, 2 RS.AddNew RS("FirstName") = Request.Form("txtFName") RS("Surname") = Request.Form("txtSName") RS("HouseName") = Request.Form("txtHouseName") RS("Address") = Request.Form("txtAddress") RS("City") = Request.Form("txtCity") RS("Postcode") = Request.Form("txtPostcode") RS("Telephone") = Request.Form("txtTel") RS("Email") = Request.Form("txtEmail") RS("Fund") = Request.Form("txtFund") RS.Update Dim CustID CustID = RS("CustID") RS.Close set RS = nothing conn.close set conn = nothing %> <script language="javascript" type="text/javascript"> alert("Your Customer ID is '<%=CustID%>'"); window.location.href = "index.htm"; </script><% %> <br> <br> </body> </html> Index.htm: <html> <head> <title>Login page</title> </head> <body> <br> <br> <br> <table border = "0" align = "center"> <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr> <tr><td> <h1 align = center>Please login or register</h1></td></tr><tr><td> <table align = "center" border = "0" cellspacing = "10" cellpadding = "10"><tr><td> <form method = "POST" name = "frmLogin" action = "CheckID.asp"> <p>Customer ID <input type = "text" name = "txtCustID" size = "10"></p></td><td> <input type = "submit" value = "login" name = "btnLogin" OnClick = ""></tr> </td></tr> <tr><td align = "left"><a href="form.htm">Want to register?</a></td></tr> <tr><td align = "left"><a href="AddToStock.htm">Want to update stock?</a></td></tr> </table> </table> </body> </html>
|
|
| |
|
|
|
|
|