DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Redirect using post

  1. #1
    Join Date
    May 2007
    Posts
    59

    Redirect using post

    Ok, I'm using a form to get a login and a password. I need to send those two variables to another page which handles the actual login. I'm using JavaScript to check if the login and password field is filled in and then I'm trying to send that information to the other page. But now I got a problem. How do I use the "POST" method with JavaScript? Because I don't want to make an url like "accessPage.asp?login=name,password=lookatmypassword".

  2. #2
    Join Date
    Mar 2005
    Location
    Los Angeles, Calif. AKA: Gangsta Yoda™
    Posts
    455
    You wouldnt pass any login credientials in the url. You would pass them to your database connection and validate and return with a pass or fail. Then if you want you can create a session variable or cookie to set the valid logon state and allow the redirect to the authenticated page. On that page's load event you will validate the session variable or cookie to make sure they just didnt bookmark the link and try to pass the login verification.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer code questions via PMs.
    Microsoft MVP 2006-2009
    Office Development FAQ (VBA, VB6, VB.NET, C#)
    Software Engineer MCP (VB6 & .NET)
    Reps & Rating PostsVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address List

  3. #3
    Join Date
    May 2007
    Posts
    59
    Cool, thanks. I'll see if I can work with that.

  4. #4
    Join Date
    May 2007
    Posts
    59
    Ok, slight new problem with my cookies.

    First I make my cookie in the javascript:
    document.cookie= "Login="+document.myform.txtLogin.value;

    But when I want to ask it again in the next page, using ASP, I do:
    dim log
    log = Request.Cookies("Login")

    But then it gives me a problem about not being able to work with that and if I use "log.string" I get an error saying I need a "ValueOfLogin" object (it gives the value that I want to hand down), but all I want is the "ValueOfLogin" as a string.

  5. #5
    Join Date
    Mar 2005
    Location
    Los Angeles, Calif. AKA: Gangsta Yoda™
    Posts
    455
    Hmm, I dont deal with cookies much as I prefer session variables. As long as you manage them properly (clearing/destroying when not longer needed) they wont affect any server performance.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer code questions via PMs.
    Microsoft MVP 2006-2009
    Office Development FAQ (VBA, VB6, VB.NET, C#)
    Software Engineer MCP (VB6 & .NET)
    Reps & Rating PostsVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address List

  6. #6
    Join Date
    May 2007
    Posts
    59
    I'm not worried about the server working (it'll work fine), but the retrieving doesn't work. I use a cookie and when I try to retrieve it, it gives me a blanc variable.

  7. #7
    Join Date
    May 2007
    Posts
    59
    It is possible to send a cookie using JavaScript and requesting it back with ASP, isn't it. Cause at the moment my problem is that it thinks that what I want to send is an object instead of a simple string.

  8. #8
    Join Date
    May 2007
    Posts
    59
    Ok, I'll ask another question (I'm full of those, aren't I).

    I'm on my access page (determines if I may log on with the login and password provided). To keep things a bit safe, I'm using a parameter:

    Code:
    set cmm = Server.CreateObject("ADODB.Command")
    cmm.ActiveConnection = cnn
    cmm.CommandText = "select * from tblDocent where Docentnummer = ? and paswoord = ?"
    set prm = cmm.CreateParameter("1", adVarChar, adParamInput, 50, Request.QueryString("log"))
    cmm.Parameters.Append prm
    set prm = cmm.CreateParameter("2", adVarChar, adParamInput, 50, Request.QueryString("pass"))
    cmm.Parameters.Append prm
    
    cmm.execute
    This way you can't easely cheat your way into my website. Don't worry about improving my code, I don't need that much security.

    At line
    Code:
    set prm = cmm.CreateParameter("1", adVarChar, adParamInput, 50, Request.QueryString("log"))
    my browser gives me the error:
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
    In "Request.QueryString("log")" there is only some text, nothing special.

Similar Threads

  1. Replies: 1
    Last Post: 10-06-2000, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center