Login form asp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • j0rdanf1
    New Member
    • Oct 2006
    • 35

    Login form asp

    Hi I have been asked to create a simple login form for a website and due to the lack of knowledge im struggling, so far I have a form which posts the information to the check.asp section

    <% @language="vbsc ript"%><%
    '#Connect to SQL database#'
    Dim objConn, objRs, strSQL
    Set objConn = Server.CreateOb ject("ADODB.Con nection")
    objConn.Open "dsn=Oracle;uid =user1;pwd=pass word;"
    set objRs=objConn.e xecute(strSQL)
    %>


    <%

    frmuserid = Request.form("f rmuserid")
    frmpassword = Request.form("f rmpassword")

    strSQL = "SELECT * FROM login WHERE userid = '"&frmUserid &"' AND password = '"&frmpassword& "'"

    Set objRs = objConn.execute (strSQL)

    If (objRs.BOF) then
    response.write ("Incorrect login, please try again.")
    Response.Redire ct "login.asp"

    ELSE

    Response.Cookie s("Login")("frm userid") = frmuserid
    Response.Cookie s("Login").Expi res = Date + 1
    Response.Redire ct "welcome.as p"

    End If
    %>

    <html>
    <head>
    <title>check</title>
    </head>
    <html>
    <head>
    <title>check</title>
    </head>



    <body>Checking. ........</body>
    </html>

    Now to me that should check the previous forms data and check it against the database but all I get is an uloadable page.

    Any suggestions to put me on the right track?

    Cheers
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    What do you mean by uloadable page?
    Are you not able to redirect to the next page after doing valid login?
    Please check your <form> tag. It should be like this:
    e.g.

    Login.asp

    <Form method ="post" action ="Login1.asp ">
    <Input type ="text" value = "" Name ="frmuserid" >
    <Input type ="text" value = "frmPasswor d">
    <input id="Submit1" type="submit" value="submit" />
    </Form>

    When you will submit the form your data will be submitted to the next
    page called as Login1.asp.

    Login1.asp
    Code:
    <%
        Dim login
        Dim pwd
    
       login = Request.Form("frmuserid")
       pwd = Request.Form("frmPassword")
     
      strSQL = "SELECT * FROM login WHERE userid = '"&frmUserid&"' AND password = '"&frmpassword&"'"
    
    Set objRs = objConn.execute(strSQL)
    
    If (objRs.BOF) then 
    response.write ("Incorrect login, please try again.")
    Response.Redirect "login.asp"
    
    ELSE
    
    Response.Cookies("Login")("frmuserid") = frmuserid
    Response.Cookies("Login").Expires = Date + 1
    Response.Redirect "welcome.asp"
    
    End If
    
      %>



    Originally posted by j0rdanf1
    Hi I have been asked to create a simple login form for a website and due to the lack of knowledge im struggling, so far I have a form which posts the information to the check.asp section

    <% @language="vbsc ript"%><%
    '#Connect to SQL database#'
    Dim objConn, objRs, strSQL
    Set objConn = Server.CreateOb ject("ADODB.Con nection")
    objConn.Open "dsn=Oracle;uid =user1;pwd=pass word;"
    set objRs=objConn.e xecute(strSQL)
    %>


    <%

    frmuserid = Request.form("f rmuserid")
    frmpassword = Request.form("f rmpassword")

    strSQL = "SELECT * FROM login WHERE userid = '"&frmUserid &"' AND password = '"&frmpassword& "'"

    Set objRs = objConn.execute (strSQL)

    If (objRs.BOF) then
    response.write ("Incorrect login, please try again.")
    Response.Redire ct "login.asp"

    ELSE

    Response.Cookie s("Login")("frm userid") = frmuserid
    Response.Cookie s("Login").Expi res = Date + 1
    Response.Redire ct "welcome.as p"

    End If
    %>

    <html>
    <head>
    <title>check</title>
    </head>
    <html>
    <head>
    <title>check</title>
    </head>



    <body>Checking. ........</body>
    </html>

    Now to me that should check the previous forms data and check it against the database but all I get is an uloadable page.

    Any suggestions to put me on the right track?

    Cheers

    Comment

    • j0rdanf1
      New Member
      • Oct 2006
      • 35

      #3
      Thanks for the quick response, my login.asp page his this form, it seems ok to me it attempts to goto the next page but gets this message:

      res://ieframe.dll/dnserrordiagoff .htm#ftp://username:password@129.110.11.182/check.asp

      form on login.asp
      --------------------------
      Code:
      <html>
      <head>
      <title>login</title>
      </head>
      
      <body>
      <form action="check.asp" method="post">
          <table>
      	<tr>
      	<td>Username:</td>
      	<td><input name="frmuserid" type="text" size="30" maxlength="25" /></td>
      	</tr>
      	<tr>
      	<td>Password:</td>
      	<td><input name="frmpassword" type="password" size="30" maxlength="25" /></td>
      	</tr>
      	<tr>
      	<td><div align="left"><a href="register.asp" class="style13">Sign up....  </a></div></td>
      	<td align=right><input type="image" src="submit.jpg" alt="loginsubmit"/></td>
      	</tr>
      	</table>   
      	
      </form>
      </body>
      </html>

      Comment

      • j0rdanf1
        New Member
        • Oct 2006
        • 35

        #4
        After messing about with this nearly all of today im still no closer but im 100% sure its not a fault on the form part, its got to be the next step, is the code wrong?

        Code:
        <!--#include file="Connections/connect.asp" -->
        <%
        userid = Request.form("userid")
        password = Request.form("password")
        
        strSQL = "SELECT * FROM login WHERE userid = '"&userid&"' AND password = '"&password&"'"
        Set objRs = objConn.execute(strSQL)
        
        If (objRs.BOF) then 
        
        Response.Redirect "login.asp?try again"
        Else 
        Response.Cookies("login1")("userid") = userid
        Response.Cookies("login1").Expires = Date + 1
        Response.Redirect "welcome.asp"
        
        End If
        %>
        when i type in a login detail i receive this info on the next page

        Code:
        <% intUserid = Request.form("intUserid") txtUserpwd = Request.form("txtUserpwd") strSQL = "SELECT * FROM tblUser WHERE intUserid = '"&intUserid&"' AND txtUserpwd = '"&txtUserpwd&"'" Set objRs = objConn.execute(strSQL) If (objRs.BOF) then Response.Redirect "stafflogin.asp?errorcode=3000002" Else Response.Cookies("StaffLogin")("intUserid") = intUserid Response.Cookies("StaffLogin").Expires = Date + 1 Response.Redirect "admin.asp" End If %>

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          It looks like scripts aren't turned on either on your server, or for this particular folder. This should be a simple server setting.

          Jared

          Comment

          • j0rdanf1
            New Member
            • Oct 2006
            • 35

            #6
            Originally posted by jhardman
            It looks like scripts aren't turned on either on your server, or for this particular folder. This should be a simple server setting.

            Jared
            According to the oracle server, it states the connection is ok? maybe best check with the server team,

            though does the script look ok, no obvious mistakes?

            Comment

            • jhardman
              Recognized Expert Specialist
              • Jan 2007
              • 3405

              #7
              Originally posted by j0rdanf1
              According to the oracle server, it states the connection is ok? maybe best check with the server team,

              though does the script look ok, no obvious mistakes?
              Yeah, the script looks OK, it just looks like the script is not being executed. Try a really simple script just to make sure:
              [code=asp]<%
              response.write "<p>Hello world." %>[/code]Let me know what happens.

              Jared

              Comment

              • j0rdanf1
                New Member
                • Oct 2006
                • 35

                #8
                Originally posted by jhardman
                Yeah, the script looks OK, it just looks like the script is not being executed. Try a really simple script just to make sure:
                [code=asp]<%
                response.write "<p>Hello world." %>[/code]Let me know what happens.

                Jared
                Thanks mate, I will give it a go and post back here, either way I am seeing the server team on thursday to have a quick chat about it.

                Cheers

                Comment

                • j0rdanf1
                  New Member
                  • Oct 2006
                  • 35

                  #9
                  Thanks mate, it was the server at fault, cheers for everyones input

                  Comment

                  • somuchbetta
                    New Member
                    • Mar 2008
                    • 5

                    #10
                    Originally posted by j0rdanf1
                    Thanks mate, it was the server at fault, cheers for everyones input
                    Hi there,

                    I am tryin to create a similar log in session to yours - being through the thread and cant seem to get it write. can you please help by telling me the steps. thanks

                    Comment

                    • jhardman
                      Recognized Expert Specialist
                      • Jan 2007
                      • 3405

                      #11
                      Originally posted by somuchbetta
                      Hi there,

                      I am tryin to create a similar log in session to yours - being through the thread and cant seem to get it write. can you please help by telling me the steps. thanks
                      starting ... where? How much do you have so far? What doesn't work?

                      Jared

                      Comment

                      • somuchbetta
                        New Member
                        • Mar 2008
                        • 5

                        #12
                        Originally posted by jhardman
                        starting ... where? How much do you have so far? What doesn't work?

                        Jared
                        I have been able to get it to work - but the problem i am having now is restricting the access to only active members....I have a field in my members table called status and the data in there wither active or inactive. I have tried the code below, but i keep getting the error msg...
                        Code:
                        Microsoft OLE DB Provider for ODBC Drivers error '80004005'
                        
                        [Oracle][ODBC][Ora]ORA-00933: SQL command not properly ended
                        
                        /student/04244825/sab2/checkmember.asp, line 20
                        Member login code:
                        [code=asp]
                        <form action="checkme mber.asp" method="post">
                        Username: <input type="text" name="username" />
                        <br /><br />

                        Password:<input type="password" name="pword" />
                        <br /><br />
                        <input type="submit" value="Log in" />
                        [/code]
                        Check Member:
                        [code=asp]
                        <%@LANGUAGE="VB SCRIPT"%>

                        <%
                        Dim objConn, objRs, strSQL
                        Set objConn = Server.CreateOb ject("ADODB.Con nection")
                        objConn.Open "dsn=Oracle;uid =04244825;pwd=1 80984;"

                        %>


                        <%

                        username = Request.form("u sername")
                        pword = Request.form("p word")


                        strSQL = "SELECT * FROM MEMBERS WHERE username = '"&username& "', pword = '"&pword&"' and status = 'Active'"

                        Set objRs = objConn.execute (strSQL)

                        If (objRs.BOF) then
                        Response.Redire ct "failedlogin.ht ml"

                        ELSE

                        Response.Cookie s("Login")("use rname") = username
                        Response.Cookie s("Login")("Tru e") = "True"
                        Response.Cookie s("Login").Expi res = Date + 1
                        Response.Redire ct "myaccount. asp"

                        End If
                        %>[/code]
                        Last edited by jhardman; Mar 11 '08, 11:28 PM. Reason: put code in code tags. Please note button marked - #

                        Comment

                        • jhardman
                          Recognized Expert Specialist
                          • Jan 2007
                          • 3405

                          #13
                          Betta,

                          By the way, please put your code in code tags, this makes it much easier to read your posts, and much more likely that someone will answer you.

                          I assume it is this line:
                          Code:
                          Set objRs = objConn.execute(strSQL)
                          that caused the problem, right? Just before it, add the following, and tell me what the output is:
                          Code:
                          response.write "<br>strSQL= " & strSQL & "<br>" & vbNewLine
                          Jared

                          Comment

                          • somuchbetta
                            New Member
                            • Mar 2008
                            • 5

                            #14
                            Originally posted by jhardman
                            Betta,

                            By the way, please put your code in code tags, this makes it much easier to read your posts, and much more likely that someone will answer you.

                            I assume it is this line:
                            Code:
                            Set objRs = objConn.execute(strSQL)
                            that caused the problem, right? Just before it, add the following, and tell me what the output is:
                            Code:
                            response.write "<br>strSQL= " & strSQL & "<br>" & vbNewLine
                            Jared
                            OMG!! I cant believe that one liner solved the problem.... Im absolutely greatful for your help cus my deadline is 2morow... Many thanks!!!!!! :-)

                            Comment

                            • jhardman
                              Recognized Expert Specialist
                              • Jan 2007
                              • 3405

                              #15
                              Originally posted by somuchbetta
                              OMG!! I cant believe that one liner solved the problem.... Im absolutely greatful for your help cus my deadline is 2morow... Many thanks!!!!!! :-)
                              That actually shouldn't have solved anything. Hmm. I bet you had it working already, but had cached a bad version of the page. Anyway, glad it worked for you.

                              Jared

                              Comment

                              Working...