Login problem in asp vbscipt

Discussion in 'General troubleshooting' started by paulapaupau, Jun 14, 2012.

  1. Dear Someone who can help me,

    This is not working.. It only shows the password textbox and the button..


    <%
    Response.Expires = -1000
    Response.Buffer = True
    Session("UserLoggedIn") = ""
    If Request.Form("login") = "true" Then
    CheckLogin
    Else
    ShowLogin
    End If

    Sub ShowLogin
    %>



    <body background="back.jpg">

    <form name="login" id="login>

    <<h1><center> Company Name </center></h1>
    <h2><center> Project System </center></h2>
    <br/><br/><br/><p> <Center> Enter Username and Password </center> </p> <br/>
    <p><center> USER NAME <input type="text" name="username"> <br/><br/> PASSWORD <input type="password" name="pword"><br/><br/>
    <input type="submit" value="Login" >
    </center> </p>

    </form>


    </body>



    <%
    End Sub

    Sub CheckLogin
    Dim Conn, rs, sql


    set Conn = server.createobject("adodb.connection")
    Conn = "Provider=sqloledb;Data Source=datasource;" & _
    "Initial Catalog=catalog;User Id=user;Password=password;"
    Set rs = Server.CreateObject( "ADODB.Recordset" )

    sql = "SELECT * FROM CarInfo WHERE EmpID = '"&username&"'"

    Set rs = conn.execute(sql)

    rs.Open sql, Conn
    Session("UserLoggedIn") = "false"
    Do While Not rs.EOF
    If Request.form("username") = rs("EmpID") And Request.form("pword") = rs("Password") Then
    Session("UserLoggedIn") = "true"
    Exit Do
    End If
    rs.MoveNext
    Loop
    rs.Close
    Conn.Close



    If Session("UserLoggedIn") = "true" Then
    Response.Redirect "protectedpage.asp"
    Else
    Response.Write("Login Failed.<br><br>")
    ShowLogin
    End If


    End Sub
    %>

    Kindly help me.. I really need help.

    Thank you,
    Paula
     
  2. You are trying to match the textbox content to a database, yes?

    Check the database connection string. It does not look you assigning correct string

    Conn = "Provider=sqloledb;Data Source=datasource;" & _
    "Initial Catalog=catalog;User Id=user;Password=password;"
     
  3. Hi.. thank you for your reply..

    what is the right way to do that?.. I mean.. to connect my database?.. :l


    Thank you,
    Paula
     
  4. I'm using MsSQL 2005..
     
  5. Create a SQL DB from the control panel if you haven't done so.
    https://cp.Winhost.com/sites/mssqlmanager.aspx

    Once the database is created, restore your local SQL2005 to there.

    update your data source string to use the database you just created and restored.
     
    Last edited by a moderator: Oct 14, 2015

Share This Page