Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1751
Number of posts: 4473

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
dns connection Posted by abrauchi on 16 Jun 2002 at 12:25 PM
this is a script i would like to use for a website. from my understanbding this is a connectionless file. can somebody try to help me how i would change this script in a form that i can use the dns "login" with it?

<%@ Language=VBScript %>
<HTML><HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 5.0">
</HEAD>
<BODY>

<%

Dim sSQL,conn,rs
Set conn = Server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")

'DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & Server.MapPath("fpdb/login.mdb")
conn.open


strsql = "Select firstname,lastname from Results"
set rs = conn.Execute (strsql)

if (rs.BOF)and (rs.EOF) then

sSQL = "Insert into Results (firstname,lastname,User_name,pw) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"& _
Request("userid") & "', '" & Request("pw") & "')"
conn.Execute sSQL,adCmdText

else

SQL = "Delete * from Results where User_name= '" & Request.Form("userid") & "'"
conn.execute(SQL)
end if

sSQL = "Insert into Results (firstname,lastname,User_name,pw) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"& _
Request("userid") & "', '" & Request("pw") & "')"
conn.Execute sSQL,adCmdText

'close the recordset
rs.close
set rs = nothing

'close the connection
conn.close
set conn = nothing

%>

<h2>Your login details have been saved to the database<h2>
</BODY>
</HTML>

Thank you in advance

Best,

Andrea
Report
Re: dns connection Posted by abrauchi on 17 Jun 2002 at 4:51 AM
I got this part of my script to work. now i have one tiny little question and than i can use this script.

I would like to protect the index page so that you can only see it after logging into the site. therefore i created a "Check.asp" file which i include into the index page

Check.asp

<%if Request.Cookies("User_name") <> "" then
Response.Redirect ("send them to view the web site")
session("submitted")="false"
else
'send them back to login page
Response.Redirect "login.htm"
Response.End
end if%>

index.htm

<--#include file="Check.asp"-->

<html>
...
</html>

right now i always see whatever i have in the index page and i will never be redirected to the login page. Does anybody have suggestions for me?

Thank you in advance

Best,

Andrea
Report
Re: dns connection Posted by reason1000 on 17 Jun 2002 at 7:23 AM
Hello. Did you clear the cookie from your hard drive? Try
deleting it, closing all browser windows, then revisit
the index page and see if you are redirected.

Rod
reason1000



: I got this part of my script to work. now i have one tiny little question and than i can use this script.
:
: I would like to protect the index page so that you can only see it after logging into the site. therefore i created a "Check.asp" file which i include into the index page
:
: Check.asp
:
: <%if Request.Cookies("User_name") <> "" then
: Response.Redirect ("send them to view the web site")
: session("submitted")="false"
: else
: 'send them back to login page
: Response.Redirect "login.htm"
: Response.End
: end if%>
:
: index.htm
:
: <--#include file="Check.asp"-->
:
: <html>
: ...
: </html>
:
: right now i always see whatever i have in the index page and i will never be redirected to the login page. Does anybody have suggestions for me?
:
: Thank you in advance
:
: Best,
:
: Andrea
:

Report
Re: dns connection Posted by abrauchi on 17 Jun 2002 at 7:25 AM
Thank you I will try that out. I was thinking I must have had a big time error there.


Report
Re: dns connection Posted by abrauchi on 17 Jun 2002 at 7:35 AM
I think the script is almost running now. the problem is that i am having a loop. whenever i type in the right password i will be redirected to the index page but as the index page is still password protected i need to enter my password again.

is there something i can do with the following script to make the script work without a loop?

<%@ Language=VBScript %>
<%Response.Buffer=true%>
<HTML><HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 5.0">
</HEAD>
<BODY>

<%
Dim conn,rs,strsql
set conn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")

'DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & Server.MapPath("/fpdb/login.mdb")
conn.open

strsql = "Select User_name, pw From Results where User_name = '" & _
Request.Form("txtusername") & "' and pw = '" & _
Request.Form("txtpassword") & "'"
set rs = conn.Execute (strsql)

If (not rs.BOF) and (not rs.EOF) then
Response.Cookies("User_name") = rs.Fields("User_name")
Response.Redirect "http://209.133.225.148/index.asp"
else
Response.Redirect "http://209.133.225.148/wrong.htm"
end if


'close the recordset
rs.close
set rs = nothing

'close the connection
conn.close
set conn = nothing
%>
</script>

</BODY></HTML>

Thank you in advance

andrea



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.