Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Regular Coder
    Join Date
    Feb 2014
    Posts
    136
    Thanks
    33
    Thanked 0 Times in 0 Posts
    I have commented out

    if rs.EOF = true then

    and its corresponding

    end if

    and it is now inserting into the database, so I will leave things like that!

    Thank you for pointing it out. It clearly doesn't fit in there.

    I am a bit surprised by this script because I got it from here: ASP Classic Membership

    One of the error messages is also wrong because when I deliberately type a password confirmation that is different from what it's supposed to be, it tells me 'Email address is already in use' when, in fact, it should tell me: 'Password and confirmation do not match'. I have corrected that now.

    So, I should leave things as they are? Not doing any harm, is it?!

  2. #17
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,753
    Thanks
    41
    Thanked 191 Times in 190 Posts
    well no that is correct for a recordset, it is how you cycle through it. You should check and if it has more than one row error out, otherwise grab that first row. But, now that I look at you link this is sooo much easier to follow :P So can you post your entire Register.asp page so we can have a fresh look?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  3. #18
    Regular Coder
    Join Date
    Feb 2014
    Posts
    136
    Thanks
    33
    Thanked 0 Times in 0 Posts
    Hello alykins

    Yes, here is the whole of Register1.asp:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>ASP Register</title>
    <link href="Site.css" rel="stylesheet">
    </head>
    <body>
    <div id="main">
    
    <%
    username = ""
    password = ""
    confirmPassword = ""
    strEmail = ""
    ErrorMessage = ""
    
    if request.form <> "" then
    username = Request.Form("username")
    password = Request.Form("password")
    confirmPassword = Request.Form("confirmPassword")
    strEmail = Request.Form("strEmail")
    
      if strEmail="" or password="" then
         ErrorMessage = "You must specify both email and password."
      end if
      if password <> confirmPassword then
        ErrorMessage = "Password and confirmation do not match."
      end if
    
      if ErrorMessage = "" then 
        set conn = Server.CreateObject("ADODB.Connection")
    
     conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    
     conn.Open("E:\myDatabase.mdb")
    
        set rs = Server.CreateObject("ADODB.recordset")
        rs.Open "Select * FROM userlist WHERE strEmail = '" & strEmail & "'", conn
        'if rs.EOF = true then
          
    sql="INSERT INTO userlist ([username], [password], strEmail) VALUES ('" & username & "','" & password & "', '" & strEmail & "')"
          
    conn.Execute(sql)
    
    'Response.Write(SQL)
    'Response.End
    
          Response.Redirect("success.asp")
         else
          ErrorMessage = "Password and confirmation do not match."
        'end if
      end if
    end if
    
    if ErrorMessage <> "" then
      response.write("<p>" & ErrorMessage & "</p>") 
      response.write("<p>Please correct the errors and try again.</p>") 
    end if
    %>
    
    <h1>Register</h1>
    <form method="post" action="Register1.asp">
     <fieldset>
    <legend>Sign-up Form</legend>
    <ol>
    
    <li>
     <label>Username:</label>
    <input type="text" id="username" name="username" />
     </li>
    
    <li>
    <label>Password:</label>
    <input type="password" id="password" name="password" />
    </li>
    
    <li>
    <label>Confirm Password:</label>
    <input type="password" id="confirmPassword" name="confirmPassword" />
    </li>
    
    <li>
     <label>Email:</label>
    <input type="text" id="strEmail" name="strEmail" />
     </li>
    
    <li>
    <p><input type="submit" value="Register" /></p>
    </li>
    </ol>
    </fieldset>
    </form>
    
    </div>
    </body>
     </html>

  4. #19
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,753
    Thanks
    41
    Thanked 191 Times in 190 Posts
    You are probably running into trouble and setting the error message in here...
    Code:
    if request.form <> "" then
    username = Request.Form("username")
    password = Request.Form("password")
    confirmPassword = Request.Form("confirmPassword")
    strEmail = Request.Form("strEmail")
    
      if ErrorMessage = "" then 
        set conn = Server.CreateObject("ADODB.Connection")
        .....
        .....
        Response.Redirect("success.asp")
      else
          ErrorMessage = "Password and confirmation do not match."    
      end if
      
    end if
    *Removed extra code*

    See how you drop into the if statement if it's not ""? You then lose what it was set to originally. I am guessing though from what I can see, and your comment of you changed value that you have corrected the issue? or am I missing something your new question? (sorry if I am :P )

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  5. #20
    Regular Coder
    Join Date
    Feb 2014
    Posts
    136
    Thanks
    33
    Thanked 0 Times in 0 Posts
    I am having success of a kind - thanks to you - in that the purpose of my original question was how to insert the 'Register new user' form data into the Access database. I have tried it just now and that is, indeed, working.

    What is odd is that after pressing 'submit', I am taken to the login form (Login.asp): 'http://www.bayingwolf.com/schoolsReg/Login.asp'

    But there is no reference in Register1.asp to Login.asp. I have a form called Login.asp on the server in the same folder as Register.asp, but it is not referred to in the Register.asp script. On the contrary, if the data is successfully inserted into the database, I should be taken to a file called success.asp!

    Still, I feel as if I am halfway there, and thank you for your patience.

  6. #21
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,753
    Thanks
    41
    Thanked 191 Times in 190 Posts
    glad you have it working some that is odd it is redirecting you to the login.asp page instead... my guess is another piece of code somewhere (well it would have to be "somewhere") good luck

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •