Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

dns connection

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 %>





<%

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

%>

Your login details have been saved to the database



Thank you in advance

Best,

Andrea

Comments

  • abrauchiabrauchi Posts: 14Member
    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"-->


    ...


    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
  • reason1000reason1000 Posts: 1Member
    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"-->
    :
    :
    : ...
    :
    :
    : 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
    :

  • abrauchiabrauchi Posts: 14Member
    Thank you I will try that out. I was thinking I must have had a big time error there.


  • abrauchiabrauchi Posts: 14Member
    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%>





    <%
    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
    %>




    Thank you in advance

    andrea
Sign In or Register to comment.