cflintten
02-19-2007, 03:28 AM
I am trying to set up a username and password database using Microsoft Access through an ASP form. I have a page where I can add administrators and users, but when I attempt to add one it comes to a page stating that I have an internal error. Here is my first page and my asp form:
<%Response.Buffer=TRUE%>
<%IF session("admin") = FALSE THEN Response.Redirect "admin.asp"%>
<html>
<head>
<title>Admin</title>
</head>
<body>
<table border="0" width="100%">
<tr>
<td width="33%" colspan="3" valign="bottom"><form method="POST" action="add.asp"><b><font size="2" face="Comic Sans MS">Add User</font></b></td>
</tr>
<tr>
<td width="33%"><font size="2" face="Comic Sans MS">Email Address<br>
<input type="text" name="T1" size="30"></font></td>
<td width="33%"><font size="2" face="Comic Sans MS">Password<br>
<input type="text" name="T2" size="20"></font></td>
<td width="34%" valign="bottom"><font size="2" face="Comic Sans MS"> <br><input type="submit" value="Add User" name="B1"></font></td>
</tr>
<tr>
<td width="33%" colspan="3" valign="bottom"></form><form method="POST" action="add.asp"><b><font size="2" face="Comic Sans MS">Add Administrator</font></b></td>
</tr>
<tr>
<td width="33%"><font size="2" face="Comic Sans MS">Email Address<br>
<input type="text" name="T3" size="30"></font></td>
<td width="33%"><font size="2" face="Comic Sans MS">Password<br>
<input type="text" name="T4" size="20"></font></td>
<td width="34%" valign="bottom"><font size="2" face="Comic Sans MS"> <br><input type="submit" value="Add Admin" name="B1"></font></td>
</tr>
<tr>
<td width="33%" colspan="3"><font size="2" face="Comic Sans MS"></form><a href="delete.asp?which=users"><b>Go
To Delete User</b></a></font></td>
</tr>
<tr>
<td width="33%" colspan="3"><a href="delete.asp?which=admin"><b><font size="2" face="Comic Sans MS">Go
To Delete Administrator</font></b></a></td>
</tr>
</table>
</body>
</html>
<%
'here is the connection string
Set conn = server.createobject("adodb.connection")
'this connection uses JET 4 it is the prefered method of connecting to an access database
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("http://mypage.org/slog/login.mdb")
'if you cant use JET then comment out the line above and uncomment the line below
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("/slog/login.mdb")
conn.Open DSNtemp
'here we are determining which form its from and getting the info from the form
'the first two represent the user form
'we will use this to add to the database
If Request.Form("T1") > "" Then
uid = Request.Form("T1")
pwd = Request.Form("T2")
Else
uid = Request.Form("T3")
pwd = Request.Form("T4")
End If
If Request.Form("T1") > "" Then
SQL = "Insert INTO users (uid,pwd) Values ('" & uid & "','" & pwd & "')"
Else
SQL = "Insert INTO admin (uid,pwd) Values ('" & uid & "','" & pwd & "')"
End If
Conn.Execute(SQL)
Conn.Close
Response.Redirect "admin2.asp"
%>
Any help would be greatly appreciated!
<%Response.Buffer=TRUE%>
<%IF session("admin") = FALSE THEN Response.Redirect "admin.asp"%>
<html>
<head>
<title>Admin</title>
</head>
<body>
<table border="0" width="100%">
<tr>
<td width="33%" colspan="3" valign="bottom"><form method="POST" action="add.asp"><b><font size="2" face="Comic Sans MS">Add User</font></b></td>
</tr>
<tr>
<td width="33%"><font size="2" face="Comic Sans MS">Email Address<br>
<input type="text" name="T1" size="30"></font></td>
<td width="33%"><font size="2" face="Comic Sans MS">Password<br>
<input type="text" name="T2" size="20"></font></td>
<td width="34%" valign="bottom"><font size="2" face="Comic Sans MS"> <br><input type="submit" value="Add User" name="B1"></font></td>
</tr>
<tr>
<td width="33%" colspan="3" valign="bottom"></form><form method="POST" action="add.asp"><b><font size="2" face="Comic Sans MS">Add Administrator</font></b></td>
</tr>
<tr>
<td width="33%"><font size="2" face="Comic Sans MS">Email Address<br>
<input type="text" name="T3" size="30"></font></td>
<td width="33%"><font size="2" face="Comic Sans MS">Password<br>
<input type="text" name="T4" size="20"></font></td>
<td width="34%" valign="bottom"><font size="2" face="Comic Sans MS"> <br><input type="submit" value="Add Admin" name="B1"></font></td>
</tr>
<tr>
<td width="33%" colspan="3"><font size="2" face="Comic Sans MS"></form><a href="delete.asp?which=users"><b>Go
To Delete User</b></a></font></td>
</tr>
<tr>
<td width="33%" colspan="3"><a href="delete.asp?which=admin"><b><font size="2" face="Comic Sans MS">Go
To Delete Administrator</font></b></a></td>
</tr>
</table>
</body>
</html>
<%
'here is the connection string
Set conn = server.createobject("adodb.connection")
'this connection uses JET 4 it is the prefered method of connecting to an access database
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("http://mypage.org/slog/login.mdb")
'if you cant use JET then comment out the line above and uncomment the line below
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("/slog/login.mdb")
conn.Open DSNtemp
'here we are determining which form its from and getting the info from the form
'the first two represent the user form
'we will use this to add to the database
If Request.Form("T1") > "" Then
uid = Request.Form("T1")
pwd = Request.Form("T2")
Else
uid = Request.Form("T3")
pwd = Request.Form("T4")
End If
If Request.Form("T1") > "" Then
SQL = "Insert INTO users (uid,pwd) Values ('" & uid & "','" & pwd & "')"
Else
SQL = "Insert INTO admin (uid,pwd) Values ('" & uid & "','" & pwd & "')"
End If
Conn.Execute(SQL)
Conn.Close
Response.Redirect "admin2.asp"
%>
Any help would be greatly appreciated!