| | |
page not redirecting - redirect2page('members.php');
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2006
Posts: 3
Reputation:
Solved Threads: 0
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:
[php]<?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);
?>
[/php] 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 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:
[php]<?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);
?>
[/php] 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.
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.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
I just found your other post:
so it is the server.... maybe posting the redirect function could help..
•
•
•
•
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
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Try
header("location: http://server-to-redirect.com");
pass this above any HTML tags or else it would show errors
header("location: http://server-to-redirect.com");
pass this above any HTML tags or else it would show errors
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
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.)
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.)
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
•
•
•
•
Originally Posted by Puckdropper
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.)
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.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
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).
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).
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
•
•
Join Date: Jul 2009
Posts: 9
Reputation:
Solved Threads: 0
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.
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
![]() |
Similar Threads
- PHP Help - Display forum online and total members on main page (PHP)
- updating 2 HTML tables on one PHP page (PHP)
Other Threads in the PHP Forum
- Previous Thread: Query Problem
- Next Thread: How to...
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






