473,698 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(te p_href_link(FIL ENAME_CHECKOUT_ SUCCESS, '1', 'SSL'));
function tep_redirect($u rl) {
if ( (ENABLE_SSL == true) && (getenv('HTTPS' ) == 'on') ) { // We
are loading an SSL page
if (substr($url, 0, strlen(HTTP_SER VER)) == HTTP_SERVER) { //
NONSSL url
$url = HTTPS_SERVER . substr($url, strlen(HTTP_SER VER)); //
Change it to SSL
}
}

header('Locatio n: ' . $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 6127
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**********@g mail.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("Locatio n: 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**********@g mail.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("Locatio n: 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("Locatio n: 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
5655
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 header('Location: ...) jump to page A on success or falls through to the jump to page B. This is the code: if ( mysql_query( 'LOCK TABLES tableX WRITE', $link ) ) { mysql_query( $q, $link ) ; // store the record
6
3430
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 to have the session_start(); at the top of the page as well. So when you have two things that need to be the first which do you put first? And if I put one before the other will that cause problems? Below is a copy of the php from my page. It...
7
2877
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() function. For example: header("Location:member.php"). I tried changing the header() command in a few ways: header("Location:/member.php"), header("Location:./member.php"), header("Location:http://www.site.com/member.php"). But none of these made...
6
2883
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 -> /this/that/the.other.thing.html, then redirect.cgi?xyz results in the page /this/that... being sent. redirect.cgi is usually in another directory than the page it is to supply. This works fine as far as it goes. A problem arises when the actual...
23
3637
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 page I don't get any session variable values! BTW, I used a relative location in the Location header, not an absolute URL. The behavior looks like it started another session, but it should not have. Ideas? TIA,
2
8918
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' ); I'd like to use particular read out data from my database (URL) (variable $result).
6
5453
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)) && ($name='valid')){ // insert some data into MySQL.
12
1896
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{ if ($LName=""){ header('Location:/verify_lname.htm'); }
2
12937
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 they can keep track of the criteria as they scroll since there can be upwards of 1000 or more patients in the table. The way I got this to work was to enter the information in a table via C# by storing it in a label. This works fine and scrolls...
0
8675
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.