PHP Script that redirects a user if they have been authenticated or not?

Discussion in 'PHP' started by jems ander, Feb 27, 2013.

  1. #1
    I'm new to PHP (1 and a half months in) and for my intranet I have setup a login form and the database for it and I would like it to redirect a user depending on if they have inputted the correct username and password or haven't. So a user goes to login, inputs the correct information and then gets redirected to the members index, but another user goes to login, inputs an incorrect username and password and gets redirected back to the login area. Does anyone have a script for this as ive been searching around for one and they only seem to concern drupal and wordpress not a hard coded site like mine? Thanks wordpress drupal nyc
     
    Last edited: Mar 4, 2013
    jems ander, Feb 27, 2013 IP
  2. zhs

    zhs Active Member

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #2
    You can do it by the following code:
    For your reference:
    http://phpsnips.com/4/Simple-User-Login#.US5WXlccObM
     
    zhs, Feb 27, 2013 IP
  3. Magina™

    Magina™ Active Member

    Messages:
    258
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    That will be do in your conditions or maybe you can post your codes here and we will try to give our help.
     
    Magina™, Mar 13, 2013 IP
  4. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    There are a couple ways to go about this. It sounds like zhs's answer will be what your looking for but keep in mind as you tumble down the rabbit whole and begin to create more complex pages your only able to utilize one header() call in your code so you may wish to redirect using another method. If you care to examine the issue this link should help: http://www.webmasterworld.com/forum88/1011.htm

    I only bring this up because whenever I began I was asking the same types of questions about redirection and someone was nice enough to show me the multiple ways of going about it...happy hunting my fellow droogie :)
     
    pHrEaK, Mar 19, 2013 IP