#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0

    Redirection based on query result...?


    I have a quiz that writes the results to an Access db. When the user logs in, I want it to redirect them based on their score.

    I want them to login and get directed to page 2.

    Page 2 queries the db based on the user/pass.

    If the quizcompleted=0, they get directed to the quiz.

    If the quizcompleted=1, they get directed to a page that says "You've taken the quiz and your score was _________ ."

    The problem is that I am new and my PHP knowledge isn't helping me do this in ASP. Any help on how to do this would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Melbourne, Australia
    Posts
    212
    Rep Power
    12
    put the following code into your page 2, after the login has been validated.

    Code:
    <% 
    If validlogon Then
    
         Select Case rsResults("quizcompleted")
              Case 0
                   Response.Redirect (address of quiz here)
              Case 1
                  Response.Redirect (address of quiz completed page)
              Case Else
                  'no other result
          End Select
    
    else
         Response.Redirect (invalid logon on page)
    end if
    
    %>
    You would need to either pass the quiz result as a parameter in the redirect (i.e. page.htm?QuizScore=<users score>) or re-query the database at the other page.

    You could also use If....then....else statements, it's up to you.
    Last edited by mohecan; May 19th, 2003 at 11:12 PM.
    How can I soar like an eagle when
    I'm flying with turkey's?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0
    Edit:

    Ok I got the conditional statements there and the info posted appropriately, but I ran into another problem. I'm going to post the new problem seperately since it's completely different. Thanks again!
    Last edited by Foundation; May 21st, 2003 at 05:33 PM.

IMN logo majestic logo threadwatch logo seochat tools logo