PDA

View Full Version : i need help with my asp script



aron
March 5th, 2002, 20:15
herre is my website http://202.94.83.158/outlook/newlogin/login.asp
login with abu password aron

the problem im running into is im trying to get once you login (you will see what i mean when you login) the welcome thing to say welcome(whoever the user is) eg welcome john.. i have tried to all sorts of thing but cant seem to get it to work can somone look at my code/website and see what i am doing wrong please..

(im grabbing/putting information into an access database)

the login page code
<%
'Option Explicit
Dim strError, strSQL, objRS, objrsFirstName
'see if the form has been submitted
If Request.Form("action")="login" Then
'the form has been submitted

'// validate the form

'check if a username has been entered
If Request.Form("Userid") = "" Then _
strError = strError & "- Please enter a username<br>" & vbNewLine

'check if a password has been entered
If Request.Form("password") = "" Then _
strError = strError & "- Please enter a password<br>" & vbNewLine

'// check if an error has occured
If strError = "" Then
'continue
'include database connection code
%>
<!--#include file="inc-dbconnection.asp"-->
<%

'// create the SQL
strSQL = "SELECT ID, password FROM tblLogin WHERE Userid='" & _
fixQuotes(Request.Form("Userid"))&"'"

'// run the SQL
Set objRS = objConn.Execute(strSQL)
'// see if there are any records returned
If objRS.EOF Then
Session("FirstName") = objRS("FirstName")
'no username found
strError = "- Invalid username or password<br>" & vbNewLine
Else
'check password
If objRS("password")=Request.Form("password") Then
'username/password valid
'save session data
Session("loggedin") = True
Session("UserID") = objRS("id")
Session("Password") = objRS("Password")

'redirect to members area
Response.Redirect ("open.asp")
Response.End
Else
'invalid password
strError = "- Invalid username or password<br>" & vbNewLine
End If
End If

End If
If strError <> "" Then
'output the error message
'add extra HTML...
strError = "<p><font color=""#FF0000"">The following errors occured:" & _
"</font><br>" & vbNewLine & strError
End If
'display message in URL.. (ie thank you for registering)
If Request.QueryString("msg") <> "" And strError = "" Then
strError = "<p>" & Request.QueryString("msg") & "</p>"
End If
End If

Function fixQuotes(strData)
fixQuotes = Replace(strData,"'","''")
End Function

're-set session data (ie log out)
Session("loggedin")=""
Session("userid")=""
%>
<html>
<head>
<title>Members Area Login</title>
</head>
<body>
<h1>Members Area Login</h1>
<p>Please enter your username and password to access the Members Area.</p>
<%=strError%>
<form action="login.asp" method="POST">
<input type="hidden" name="action" value="login">
<table border="0">
<tr>
- <td><b>Username</b></td>
- <td><input type="text" maxlength=20 name="Userid"
value="<%=Server.HTMLEncode(Request.Form("Userid"))%>"></td>
</tr>
<tr>
- <td><b>Password</b></td>
- <td><input type="password" maxlength=20 name="password"
value="<%=Server.HTMLEncode(Request.Form("password"))%>"></td>
</tr>
<tr>
- <td>-</td>
- <td><input type="submit" value="Login"></td>
</tr>
</table>
<p><a href="register.asp">Register here</a></p>
</form>
</body>
</html>

the open page code (once you passs the login)

<%
If Session("loggedin") <> True Then Response.Redirect "login.asp"
%>
<html>
<head>
<title>Members Area</title>
</head>
<body>
<h1>Members Area</h1>
<p>Welcome to our members area!</p>
<p>please <a href="logout.asp">click to logout </a></p>
<%
Response.write("Welcome: ")& Session("FirstName")
%>
Welcome <%Response.Write(Session("FirstName"))%>


please help me

regards aron palmer

coldturkey
March 6th, 2002, 02:10
Are you sure the record is in the database?
Anyway, i think yyou could have done it in a lot simpler way.

aron
March 6th, 2002, 02:23
im a new user to asp so i often take things the long way around but if your willing to point me or help me to correct this id much apreaciate it.


regards aron palmer