Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login page

Status
Not open for further replies.

SiJohn101

Technical User
Joined
Nov 13, 2001
Messages
13
Location
GB
I have the following login page

<FORM ACTION="login.asp" method="Post" name="login" onsubmit="return validate(this);">

<td align=left bgcolor=#ffff99>
<p><b><FONT color="#009933">username</B><br><INPUT TYPE="text" NAME="Username" VALUE="" SIZE="20"><p><b><FONT color="#009933">Password</b><br><INPUT TYPE="text" NAME="Password" VALUE="" SIZE="20"><br>
<P><INPUT TYPE="submit" NAME="Submit">
</form>

Which passes everything over fine to this page



<%Language="VBScript"%>
<%
Dim strSQL, objConn, objRS


strusername = request.form("Username")
strpassword = request.form("Password")

strSQL = "SELECT * from tblUsers where fldUsername = ' & Username ' & fldPassword = ' & password '"

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "TPVORCDSN"
Set objRs=objConn.Execute(strSQL)

if objRs.bof then
session("message") = "Your Login details were incorrect."
response.redirect("end if

session("fldUsername") = objRs("fldUsername")
response.redirect("
%>

But i want it so that on this next page it writes hello SiJohn101 I have tried this but to no avail. here is what is on the next page.

<%
Session("Username") = username
Response.write("Hello " & username)
%>


Cheers
 
<%
Response.write("Hello " & Session("fldUsername"))
%>

 
Hi John,

To begin, you should really change this part of your code:

if objRs.bof then

to read:

if objRs.eof then

Just because it will always return TRUE if you are checking to see if you are at the begining of the recordset.

Then on the next page, you should have this:

<%
Response.write "Hello " & session("fldUsername")
%>

that should do the trick.

Cheers,

G.



GT Interactive
-----------------------------
Components/Tools/Forums/Software/Web Services
 
I'd be suprised if you were getting anything from that sql statement. Should be a little more like this:
Code:
strusername = request.form("Username")
strpassword = request.form("Password")

strSQL = "SELECT * from tblUsers where fldUsername ='" & strUsername & "' AND fldPassword ='" & strpassword "'"
You're assigning the text box values to variables and then not using the variables.
 
I have to changed my query to how you said but it now brings up the following error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'fldUsername ='SimonJ' AND fldPassword ='Huddersfield'.

/tpv/login.asp, line 17
 
Do this:
Code:
strSQL = "SELECT * from tblUsers where fldUsername ='" & strUsername & "' AND fldPassword ='" & strpassword "'"

response.write(strSql):response.end()

This will show you the problem.
 
Its saying expected end of statement

strSQL = "SELECT * from tblUsers where fldUsername ='" & strUsername & "' AND fldPassword ='" & strpassword "'"

Afterstrpassword where the first " is.

If i remove this it brings up this

SELECT * from tblUsers where fldUsername ='SimonJ' AND fldPassword ='Huddersfield

which suggests that the strpassword is missing a ' but no matter what I do it still won't work
 
Sorry. Here is corrected sql.
Code:
strSQL = "SELECT * from tblUsers where fldUsername ='" & strUsername & "' AND fldPassword ='" & strpassword [red][b]&[/b][/red] "'"
 
Cheers for that most appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top