PDA

View Full Version : Register page


Ahmult
10-17-2005, 02:32 AM
If I have 5 field of input and only store 3 input to database. Can this work? I try something like this, but there is always the problem with connecting database. Do anyone point out this problem? :o

register.htm
<HTML>
<HEAD>
<TITLE> User Registration Form </TITLE>
</HEAD>
<BODY ALIGN= "CENTER">
<H1> User Registration Form </H1>

<FORM name= "frmRegister" action="register_me1.asp" method="post">
<P> First name: <INPUT type="text" name="txtFirstName" size="35" > <BR>
Last name: <INPUT type="text" name="txtLastName" size="35" > <BR>
User name: <INPUT type="text" name="txtName" size="35" > <BR>
Password: <INPUT type="text" name="pwd" size="35" > <BR>
Email: <INPUT type="text" name="txtEmail" size="35" > <BR>

<INPUT type = "submit" name = "butSubmit" value= "Submit" >
<INPUT type = "reset" name = "butReset" value= "Reset" >
</FORM>
</BODY>
</HTML>


Register_me1.asp

<%@ Language = JavaScript %>
<HTML>
<%
vName = Request.Form("txtName");
vPwd = Request.Form("pwd");
vEmail = Request.Form("txtEmail");
vConnString = Server.MapPath("/group1") + "\\_db\\user.mdb";
vRS = Server.CreateObject("ADODB.Recordset");
vRS.ActiveConnection = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" + vConnString;
sql="INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "'";
vRS.Source = sql;
vConn.Execute (sql);
vConn.Open;

%>
<HEAD>
<TITLE> User Registration Response </TITLE>
</HEAD>
<BODY align="center">
The information you entered: <br>
First name: <%= Request.Form("txtFirstName") %> <br>
Last name: <%= Request.Form("txtLastName") %> <br>
User name: <%= Request.Form("txtName") %> <br>
Password: <%= Request.Form("pwd") %> <br>
Email: <%= Request.Form("txtEmail") %> <br>
</BODY>
</HTML>

Bullschmidt
10-17-2005, 05:35 AM
What's the error message?

And I don't know if the following applies but if so it can be rather useful.

It would be nice to get some more diagnostic information on the error message page. So in Internet Explorer you can do this: Tools | Internet Options | Advanced | Uncheck Show friendly HTTP error messages. And it doesn't hurt anything to just keep your browser set like this.

And then when you get an error you can see more on the error page especially the code at the bottom which could be something like "Error on line 339 GetValue()) extra parenthesis"?

And here's a resource about that:

Why do I get a 500 Internal Server error for all ASP errors?
http://www.aspfaq.com/show.asp?id=2109

Ahmult
10-17-2005, 10:57 AM
Sorry about that. I am quite hurried today and miss the error

Here is my error ;)
Error Type:
Microsoft JScript runtime (0x800A1391)
'vConn' is undefined
login/register_me1.asp, line 12

glenngv
10-17-2005, 11:42 AM
As what the error says, you have not defined the variable 'vConn'.
The code should be like this:
<%
var vConn = new ActiveXObject("ADODB.Connection");
vConn.open("Driver={Microsoft Access Driver (*.mdb)};DBQ=" + vConnString + ";");
var sql = "INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "')";
vConn.execute(sql);
%>

Ahmult
10-18-2005, 03:07 AM
error again

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
/mmgroup27/loginKen/Register_me1.asp, line 13

Bullschmidt
10-18-2005, 02:20 PM
Looks like one of the following words is missing from the beginning of the SQL statement:

'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'

http://www.w3schools.com/sql/

http://www.aspfaq.com/search.asp?q=80040E14&x=6&y=4

neocool00
10-18-2005, 07:54 PM
Try making this two lines instead of one:

var sql = "INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "')";

Change to:

var sql;
sql = "INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "')";

glenngv
10-19-2005, 08:35 AM
Try making this two lines instead of one:

var sql = "INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "')";

Change to:

var sql;
sql = "INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "')";That's still the same.

Try debugging it by outputting the SQL statement.
<%
var vConn = new ActiveXObject("ADODB.Connection");
vConn.open("Driver={Microsoft Access Driver (*.mdb)};DBQ=" + vConnString + ";");
var sql = "INSERT INTO reg (Name, pw, email) VALUES ('" & vName & "', '" & vPwd & "', '" & vEmail & "')";
Response.Write("<p>"+sql+"</p>");
vConn.execute(sql);
%>
And then copy the sql displayed in the page and paste it into Access' SQL View window and then run it to verify if the syntax is correct.