Link to home
Start Free TrialLog in
Avatar of sash031299
sash031299

asked on

from form to dbase

first, i will give more points (200) to the person that gives me a good answer :) i just dont have to point now...

is there a way that i can make a web form write to a access database that i have made. all i want is something like this site. i want the user to make a account from a form, then login. i want all this info to be in a database so i can make reports on it later. can someone show me how to do this. i know how to make forms and webpages. i am only intrested to the link to the dbase... thanks \
mark
Avatar of xabi
xabi

Hi there:

Here goes a simple example in ASP:

------ 8< ------- 8< -----
srtDataBaseConnectionString = "Data Source=" & Server.MapPath ("/cgi-bin/mydatabase.mdb")
Set AdoConn = Server.CreateObject ("ADODB.Connection")
AdoConn.Provider = "Microsoft.Jet.OLEDB.4.0"
AdoConn.ConnectionString = srtDataBaseConnectionString
AdoConn.Open
sSql = "SELECT field1 FROM mytable"
set rsTmp = AdoConn.Execute (sSql)
do until rsTmp.eof
  response.write(rsTmp("myfield1") & "<br>")
  rsTmp.movenext
loop
AdoConn.close
Set AdoConn = nothing
---------- 8< ------- 8< -------
xabi
Avatar of sash031299

ASKER

thanks, but this is only part of the prob. how do i get a form to check if there is a user like that, and display a feild. like   how many points you have got left on your account. i have got a feild called "points" and i want to show it on my page depending on who logs in. thanks again :)
sUser = Request("user")
sSql = "SELECT points FROM mytable WHERE user='" & sUser & "'"
..
..
response.write(rsTmp("points"))
..
..

xabi
sorry, but where do i put this??
Adjusted points to 45
ok, i have made a form that adds data to a database. i have got two fields (username and password). all i need now is a form that checks the data, (compares the data in the database to what the use has just inputed into the form)and if the username and password is the same as in the database, loads one page, and if not, loads another (error)... how do i do this??? pls help me :)
<!--#include file="adovbs.inc"-->
<%
Dim loginName, pwd
loginname=""
pwd=""
loginName=Request.QueryString("Uname")
pwd       =Request.QueryString("pwd")
set Myconn=server.CreateObject("ADODB.connection")
Myconn.Open "DRIVER={MicroSoft Access Driver (*.mdb)};DBQ=" & server.MapPath("./test.mdb")
set rs=server.CreateObject("ADODB.recordset")
rs.open "Select * from Login where usrName='" &loginName& "' and pwd='" &pwd& "'" ,Myconn ,adOpenDynamic,adLockOptimistic
if  rs.eof then
response.redirect("page1.asp")
else
response.redirect("page2.asp")
end if      
      

%>

Adjusted points to 50
i bet this would work, but where do i put it and how do i link it to my form??
ASKER CERTIFIED SOLUTION
Avatar of FRehman
FRehman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Adjusted points to 80