www.webdeveloper.com
Results 1 to 3 of 3

Thread: After login redirect not working on server.

  1. #1
    Join Date
    May 2013
    Posts
    119

    After login redirect not working on server.

    Hi friends,
    I am facing some loging problem with my website, after loging, redirec not working on server but its working fine on local host.
    I am using this
    if(!$con||$count=="0")
    {
    $alert="<span class=error>Please check the username or password</span>";
    }
    else
    {
    $_SESSION['username']="$username";
    header("Location:admin/dashboard.php");
    }
    }

  2. #2
    Join Date
    Aug 2006
    Posts
    301
    i think Location in the header should be lower case, and all this code needs to appear in php tags at the top of the file, if it appears after the head tags it may not work and say something like 'headers already sent'

  3. #3
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Quote Originally Posted by php.net
    Note:

    HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:
    http://us3.php.net/manual/en/function.header.php

    PHP Code:

    <?php
    /* Redirect to a different page in the current directory that was requested */
    $host  $_SERVER['HTTP_HOST'];
    $uri   rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra 'mypage.php';
    header("Location: http://$host$uri/$extra");
    exit;
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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



Recent Articles