Hello,

I have the same software installed on two servers:
works: http://developdesign.com/samples/modelagency/index.php
not working: http://killertalent.com/index.php

1 example - login as 'mat / matt'
One developdesign.com page you get directed to 'members.php' page if logged in, but one killertalent.com page you get error ( or if using Firefox you go to "http://killertalent.com/processors/login.php" page )

The processors/login.php page is supposed to redirect to either 'members.php' if logged in or 'index.php' if need to register.

Could it be that developedesign.com Server API is Apache, but killertalent.com Server API is CGI/FastCGI?

CODE for login.php page with redirect code:

<?session_start();
require("../includes/vars.inc.php");
require("../includes/functions.inc.php");
require("../includes/templates.inc.php");
require("../includes/apt_functions.inc.php");

$topass=array();
if ($_SERVER['REQUEST_METHOD']=='POST') {
    $user=addslashes_mq($_POST['username']);
    $pass=addslashes_mq($_POST['password']);
    if (isset($user) && !empty($user) &&  isset($pass) && !empty($pass)) {
        db_connect();
        $query="SELECT user_id,name,membership,is_approved FROM users WHERE user='$user' AND pass='$pass'";
        if (!($res=mysql_query($query))) {error(mysql_error(),__LINE__,__FILE__);}
        if (mysql_num_rows($res)) {
            list($user_id,$name,$membership,$is_approved)=mysql_fetch_row($res);
            $_SESSION['user_id']=$user_id;
            $_SESSION['name']=$name;
            $_SESSION['membership']=$membership;
            $_SESSION['is_approved']=$is_approved;
            $query="UPDATE users SET last_visit=now() WHERE user_id='$user_id'";
            if (!($res=mysql_query($query))) {error(mysql_error(),__LINE__,__FILE__);}
            if (defined('_PCPIN_CHAT_')) {
                $is_admin='no';
                if ($membership==_ADMINLEVEL_) {
                    $is_admin='yes';
                }
                @mysql_query("INSERT INTO pcpin_users SET user='$user',lastping='".time()."',ip='".getenv('REMOTE_ADDR')."',language='english',color='#000000',level='$is_admin',sid='".session_id()."'");
                $date_time = date('YmdHis');
                @mysql_query("INSERT into pcpin_logins SET date_time='$date_time',user='$user', ip='".getenv('REMOTE_ADDR')."', password='$pass'");
                $date_time = date('d').".".date('m').".".date('Y')." ".date('H').":".date('i').":".date('s');
                @mysql_query("UPDATE pcpin_registered_users SET last_visit='$date_time',last_ip='".getenv('REMOTE_ADDR')."' WHERE user='$user'");
            }
            redirect2page('members.php');
        } else {
            $topass['message']='Invalid user or pass. Please try again!';
        }
    } else {
        $topass['message']='Invalid user or pass. Please try again!';
    }
}
redirect2page("index.php",$topass);
?>

The server configuration info:
http://developdesign.com/phpinfo.php
http://killertalent.com/phpinfo.php
Is it that the Server API on developdesign.com is Apache and the Server API on killertalent.com is CGI/FastCGI?
Is it that developdesign.com uses Zend Optimizer and killertalent.com uses eAccelerator?

Software says important to have one important directive for the directory where your installation is:
AllowOverride All
How do I tell if this directive is setup?

I dont believe the server side has anything to do with redirection problems since redirects used in PHP are normally the sending of the HTTP Redirect Header to the browser, or Document Moved Permanently etc. Header. This is the same across servers for which ever HTTP version being used. Its up the browser to follow the http protocol and implement the redirect.

However, most likely its to do with your login not working. I tested and the site http://killertalent.com/ worked fine, redirecting me to http://killertalent.com/members.php after login.

If you think its the redirect, then please post the contents of the redirect2page() function.

The login may not work because of session cookies problems or some server side error etc. So I'll bet the login is being written to the database and session, but when you were being redirected to members.php, your access (session) could not be verified. Maybe because the session cookie was not written?

So maybe the contents of members.php could help, or the function which validates the users session.

I've noticed in some applications redirects would lead to a different domain (as far as the browser is concerned) because the redirect when to www.site.com instead of site.com. I dont think this happened here since the redirects are to relative urls, but thats good to note.

I just found your other post:

Found
The document has moved here.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.34 Server at killertalent.com Port 80

so it is the server.... maybe posting the redirect function could help..

One other tip:

When sending headers and doing redirection, the full URL must be used. It will NOT accept a relative URL. (You can write a function that generates the full URL from a relative one with little difficulty.)

One other tip:

When sending headers and doing redirection, the full URL must be used. It will NOT accept a relative URL. (You can write a function that generates the full URL from a relative one with little difficulty.)

Good point there.:idea:

Also, when putting in the full url, you must be sure you use the same domain if you are using sessions.

Example:

http://www.example.com
http://example.com

Are not the same domain as far as the browser is concerned, even though they resolve to the same IP as far as the sever is concerned.

using the wrong domain breaks the users session, and thus the login does not work and needs to redirect again.

There's a more technical explanation why that works like it works. If interested, keep reading:

Both domains on and off the world wide web (www) can point to different places. An example of this is UNNA, the United Network of Newton Archives. (http://www.unna.org) Another site (which wasn't responding when I tried it) is located at (http://unna.org). Same domain name, but one's www and the other's not.

Also, sites can point to the same IP but have different domains hosted. My personal site, http://www.puckdroppers.us resolves to the same IP as Uncreative Labs (http://www.uncreativelabs.net).

I went through redirect Hell for several days. These may not be your issues but these were mine.
1. Most important: output buffering must be turned on in both php.ini files. Otherwise if anything, even white space, is sent before your header, it will fail It could be on at one server and off at the other.
2. The oddest of all: If I launched Firefox from Expression Web2 on my local host all my redirects failed. If I launched the same browser outside of Expression Web they all worked. As far as I knew the icon in Expression Web2 was no more than a shortcut which passed my current page but somehow there is a difference. All of my other navigation and urls worked fine but no redirects.

Good luck. I know how frustrating this can be.

I reckon after 3 years the OP has fixed the problem :)

lol. Maybe I should look at the dates a little closer. :)

r u using header function used in php? or u can try javascript function of window.location as well.

I reckon after 3 years the OP has fixed the problem :)

Same for you :).

LOL. My problems are resolved and this post is 3 years old. I don't know how I brought it up in the first place, must have been a search or something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.