SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Login security code re-direct an error.

    Hi,

    When a user logs in if they type in their login details incorrect it shows them an error then redirects back to the login screen.

    When they put the incorrect Security code in it shows the error but doesn't redirect back.

    How would I implement a redirect back in php?

    This is the code I am assuming I would need to add the redirect.

    PHP Code:
    if (strtoupper($_POST['code']) != $_SESSION['code']) {
            
    error('Invalid security code entered!');
        } else {
            unset(
    $_SESSION['code']);
        } 
    If anyone has any suggestions that would be great. Many thanks,

    Paul

  2. #2
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    header("Location: http://www.yourdomain.com/loginpage.php");

  3. #3
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note that the header syntax only works if you haven't sent any data to the browser already. You can alternatively use HTTP meta-refresh, although that's not guaranteed to be enabled. This is why I usually like to set a page between my login page and my entrance page, and then validate the user (via a session variable) at both locations.

  4. #4
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, the first option didn't seem to work.

    When logged in successfully it has this bit of code which I tried but it didn't work:

    PHP Code:
    output('You have successfully logged in! Please wait while we redirect you to your my account section.');
            
    redirect('/myaccount/'2); 


Bookmarks

Posting Permissions

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