473,386 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

php - header Location very slow

One
Hi guys - I have a problem after a client clicks a Confirm button on a
form - the form processes the data, inserts into a database, and then
redirects using header Location.

I have tested this on two different Linux/Apache servers. One works
perfectly, the other takes about 90 seconds to redirect.

Has anyone seen this issue before ?

It uses a function like this :

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCE SS, '1', 'SSL'));
function tep_redirect($url) {
if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We
are loading an SSL page
if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { //
NONSSL url
$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); //
Change it to SSL
}
}

header('Location: ' . $url);

tep_exit();
}
In my tests - I'll receive the confirmation email *beofre* I see the
success page in the browser!

As I say - I know the function eventually _works_ - but it was
interesting to see it work properly on the other server.

THANKS!

Dec 30 '06 #1
5 6044
One wrote:
Hi guys - I have a problem after a client clicks a Confirm button on a
form - the form processes the data, inserts into a database, and then
redirects using header Location.

I have tested this on two different Linux/Apache servers. One works
perfectly, the other takes about 90 seconds to redirect.
I suggest you use a small function that writes to a log file a small text
message and the time stamp, set this before everything you are going to do,
this way you see where the slowness comes from, can be that the second servers
connection to the database is so bad it takes it a lot longer to send the data
to the database which makes a delay before it come to the line where it does
the redirect.
--

//Aho
Dec 30 '06 #2
Syl

J.O. Aho wrote:
One wrote:
Hi guys - I have a problem after a client clicks a Confirm button on a
form - the form processes the data, inserts into a database, and then
redirects using header Location.

I have tested this on two different Linux/Apache servers. One works
perfectly, the other takes about 90 seconds to redirect.

I suggest you use a small function that writes to a log file a small text
message and the time stamp, set this before everything you are going to do,
this way you see where the slowness comes from, can be that the second servers
connection to the database is so bad it takes it a lot longer to send the data
to the database which makes a delay before it come to the line where it does
the redirect.

Hi Aho - thanks for the reply.
Actually - the database content gets inserted successfully, and then
the confirmation email goes and successfully - and then the redirect.

I know it is the redirect because I query the db and the content is
there, and I also recieve the email - all beofre I see the success page!

Dec 31 '06 #3
"Syl" <da**********@gmail.comwrote:
: Actually - the database content gets inserted successfully, and
: then the confirmation email goes successfully - and then the
: redirect.
: I know it is the redirect because I query the db and the content
: is there, and I also recieve the email - all beofre I see the success
: page!

Are you sending any output before the headers get sent?

Perhaps there's some HTML code at the top of the page before
your PHP code starts executing? The header("Location: zzz...");
is not supposed to have any output at all before it's execution.
Then make sure there's an exit(); function right after the header();
function to make sure the script stops getting executed.

Hope this helps.

--
Jim Carlock
Post replies to the group.
Dec 31 '06 #4
One

Jim Carlock wrote:
"Syl" <da**********@gmail.comwrote:
: Actually - the database content gets inserted successfully, and
: then the confirmation email goes successfully - and then the
: redirect.
: I know it is the redirect because I query the db and the content
: is there, and I also recieve the email - all beofre I see the success
: page!

Are you sending any output before the headers get sent?

Perhaps there's some HTML code at the top of the page before
your PHP code starts executing? The header("Location: zzz...");
is not supposed to have any output at all before it's execution.
Then make sure there's an exit(); function right after the header();
function to make sure the script stops getting executed.

Hope this helps.

{ sigh }

THANK YOU for taking the time to post. Turns out it is a database
select issue.

I've re-posted ....... same problem, but differnet question! :-)

Jim Carlock
Post replies to the group.
Dec 31 '06 #5
Syl wrote:
J.O. Aho wrote:
>One wrote:
>>Hi guys - I have a problem after a client clicks a Confirm button on a
form - the form processes the data, inserts into a database, and then
redirects using header Location.

I have tested this on two different Linux/Apache servers. One works
perfectly, the other takes about 90 seconds to redirect.
I suggest you use a small function that writes to a log file a small text
message and the time stamp, set this before everything you are going to do,
this way you see where the slowness comes from, can be that the second servers
connection to the database is so bad it takes it a lot longer to send the data
to the database which makes a delay before it come to the line where it does
the redirect.


Hi Aho - thanks for the reply.
Actually - the database content gets inserted successfully, and then
the confirmation email goes and successfully - and then the redirect.
I wasn't questioning that the data wasn't inserted into the database, but that
the connection to the database is slow. If there had been trouble with
inserting into the database, it had been more likely you got some error
message displayed on the web page without redirection.

I know it is the redirect because I query the db and the content is
there, and I also recieve the email - all beofre I see the success page!
If you are using header("Location: http://example.net"), and it takes time
before you get redirected, then the fault is before the header statement, as
this redirection don't allow delay (it's possible to make redirection with
delay, but then you need to set the delay in seconds and would affect the
script in both servers).

In your reply to Jim you say it's a select statement that causes the problem,
then you may better ask your question at alt.php.sql than a general php
newsgroup or a Unix newsgroup, where they may not be that interested in
answering when it comes to irrelevant things like php and Linux.

--

//Aho
Dec 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Margaret MacDonald | last post by:
I'm seeing a problem that has me flummoxed. The only thing I can think of is that I'm violating some rule I don't know about. I have some code that does some processing and then does a...
6
by: John | last post by:
Hi. I am having a few header problems at the moment with a login page. I don't have my headers at the top of the page where I've learned I need to have them. However, I also know I'm supposed...
7
by: Monty | last post by:
Something odd is happening. Scripts on several sites that collect form data, save it to a DB, then redirect the user to another page are slowing to a crawl during the redirect using the header()...
6
by: G*rd*n | last post by:
I have been using the HTTP "Location" reponse header to direct a symbolic request to a CGI program to an actual URL/file. For example, let us suppose the CGI program's table indicates xyz ->...
23
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target...
2
by: Ladbroke | last post by:
Hiya, got a little prob with the syntax for header ( ' Location .... with variable). Usually examples are given with a complete URL, like: ..... header( 'Location: login/testsite/start.php'...
6
by: P-Rage | last post by:
Hello everyone, I was wondering what could possibly cause Internet Explorer 6 to loop a page usging a header(Location:) statement. For example, a page called 'page1.php': if((isset($_POST))...
12
by: Jerim79 | last post by:
I have created a verification script to verify information and redirect the customer to the appropriate error page. For example: if ($FName=""){ header('Location:/verify_fname.htm'); } else{...
2
by: dfdavis.mtu | last post by:
I have a table that I dynamically fill with data from a database for medical companies to be able to determine if their patients meet certain criteria. However they want a fixed header for it so...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.