Help needed with asp scripting - HotUKDeals
We use cookie files to improve site functionality and personalisation. By continuing to use HotUKDeals, you accept our cookie and privacy policy.
Get the HotUKDeals app free at Google Play

Search Error

An error occurred when searching, please try again!

Login / Sign UpSubmit

Help needed with asp scripting

£0.00 @
Hi Any ASP coder's in here. Ive set up a web page which asks for a username and password. What i need now is help with scriping the following. if user1 & password 1 are correct redirect to… Read More
rashriaz Avatar
7y, 9m agoPosted 7 years, 9 months ago
Hi

Any ASP coder's in here.

Ive set up a web page which asks for a username and password.

What i need now is help with scriping the following.

if user1 & password 1 are correct redirect to = userpage1.asp
if user2 & password 2 are correct redirect to = userpage2.asp
if user3& password 3 are correct redirect to = userpage3.asp

is this possible with out databases ?
rashriaz Avatar
7y, 9m agoPosted 7 years, 9 months ago
Options

All Comments

(18) Jump to unreadPost a comment
Comments/page:
#1
what do you mean by user 1 & password 1

just static user names e.g admin admin ?

how many users are you planning of having ?

is this production or playing if it is just playing just hard code it
#2
moulez
what do you mean by user 1 & password 1

just static user names e.g admin admin ?

how many users are you planning of having ?

is this production or playing if it is just playing just hard code it


i mean

if user one enter there username and password as

admin1 and password then they will get directed to userpage1.asp

if user 2 enter there username and password as

admin2 and password then they will get directed to userpage2.asp

hope that makes more sense
#3
is there a limited amount of users (i.e. can you hard code the usernames etc ) or do you want to add users in this system ?
#4
if not just have a massive if statement for each user

Pusedo code:

if(username=="user1"&&pass=="pass"){
// direct to page 1 for that user
}
else if(username=="user2"&&pass=="pass2"){

}

if u need more than a set ammount you will have to read in from file if you dont want to store on a DB

another option is to have a massive array of users but this wont be persistant e.g. when it restarts any new users u add will be lost
#5
moulez
if not just have a massive if statement for each user

Pusedo code:

if(username=="user1"&&pass=="pass"){
// direct to page 1 for that user
}
else if(username=="user2"&&pass=="pass2"){

}

if u need more than a set ammount you will have to read in from file if you dont want to store on a DB

another option is to have a massive array of users but this wont be persistant e.g. when it restarts any new users u add will be lost



there will only be about 5 users, i will give your sulotion a go over the weekend. many thanks

will let you know how i get on :thumbsup:
#6
ive been playin with the code, but it still doesnt work. this is my code below


<%
Sub CheckLoginForm
'check if the value of the text field 'username' and 'password' are correct
If Request.Form("username") = "mic" AND Request.Form("password") = "pass" Then
Session("BlnLoggedIn") = True
Response.Redirect "svideo1.asp"
If Request.Form("username") = "mic2" AND Request.Form("password") = "pass2" Then
Session("BlnLoggedIn") = True
Response.Redirect "svideo2.asp"
Else
'if the values entered are incorrect then display the message below
Response.Write "
You are not logged in.

"
ShowLoginForm
End If
End Sub
%>
#7
hi there

it looks like you may have already seen this but have you tried this link

http://www.codefixer.com/tutorials/password_protect.asp

it is a good tutorial on how to get it up and running, the code you pasted doesn't have any obvious problems so im thinking it may be a problem else where, it may be worth breaking the if statement down in to obvious things to make sure the re-direct thing works etc

let me know how you get on
#8
moulez
hi there

it looks like you may have already seen this but have you tried this link

http://www.codefixer.com/tutorials/password_protect.asp

it is a good tutorial on how to get it up and running, the code you pasted doesn't have any obvious problems so im thinking it may be a problem else where, it may be worth breaking the if statement down in to obvious things to make sure the re-direct thing works etc

let me know how you get on


hi there

ive got it to work so 1 user can login but it doesnt work for the 2nd and 3rd users
#9
i spotted your problem there i think

incorrect login in your if statements

you go ....

if user1 then
,,,
if user2 then
...
else
....

this means if it is not user on or user two it will break because the else will pick it up

it should be

if user1 then{
log user1
}
else if user2 then{
log user 2
}
else if user3 then{
log user 3
}
else{
"no users match so end it "
}


i think this may be related to your problem

p.s. this is the syntax you should be using

<%
If A=B Then
response.write "A is equal to B"
ElseIf A=C
response.write "A is equal to C"
ElseIf A=D
response.write "A is equal to D"
Else
response.write "A doesn't equal any of them"
End If
%>

hope this helps
#10
Hmmmm, any particular reason you want to do it that way? That's about as secure as a jelly padlock.
#11
First things first, you should set the Session("BlnLoggedIn") = False before the If statements.

Also the second 'If' statement should be 'ElseIf' like moulez has suggested.
#12
yer im assuming this is a project or a proof of concept or something as this isn't "industry standard" when it comes to log on pages :)
#13
cheers guy, but how would i script the following to work?

<%
If A=B Then
response.write "A is equal to B"
ElseIf A=C
response.write "A is equal to C"
ElseIf A=D
response.write "A is equal to D"
Else
response.write "A doesn't equal any of them"
End If
%>


would it be something like

<%
If user=user1 Then
response.redirect "page1.asp"
ElseIf user=user2
response.redirect "page2.asp"
ElseIf user=user3
response.redirect "page3.asp"
Else
response.write "A doesn't equal any of them"
End If
%>
#14
rashriaz;5679585
cheers guy, but how would i script the following to work?

<%
If A=B Then
response.write "A is equal to B"
ElseIf A=C
response.write "A is equal to C"
ElseIf A=D
response.write "A is equal to D"
Else
response.write "A doesn't equal any of them"
End If
%>


would it be something like

<%
If user=user1 Then
response.redirect "page1.asp"
ElseIf user=user2
response.redirect "page2.asp"
ElseIf user=user3
response.redirect "page3.asp"
Else
response.write "A doesn't equal any of them"
End If
%>


Pseudocode fine to me, are you still having problems?
#15
<%
If Request.Form("username") = "mic" AND Request.Form("password") = "pass" Then
response.redirect "page1.asp"
ElseIf Request.Form("username") = "mic2" AND Request.Form("password") = "pass2"
response.redirect "page2.asp"
ElseIf Request.Form("username") = "mic3" AND Request.Form("password") = "pass2"
response.redirect "page3.asp"
Else
response.write "A doesn't equal any of them"
End If
%>


your looking for something close to this

just your orig code with else ifs in to make the logic work
#16
if not tried it yet, will give it a go later

thanks
#17
Thanks everyone, espically moulez

Now working perfectly
#18
Dont worry about it mate

i understand how hard it is to get your head around this stuff at the start


good to hear its working

Post a Comment

You don't need an account to leave a comment. Just enter your email address. We'll keep it private.

...OR log in with your social account

...OR comment using your social account

Thanks for your comment! Keep it up!
We just need to have a quick look and it will be live soon.
The community is happy to hear your opinion! Keep contributing!