473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Header Location

1,059 Top Contributor
Its not a php Question. Its a HTTP question

how web server send client Location header request.

The thing is, after sending "\r\n\r\n" web server start to send data to web client but even though in that situation if we create a Location header request it works
look at the below example.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "johny";
  3. header("Location: request.php");
  4. ?>
How it works?
Aug 16 '10 #1
6 2282
code green
1,726 Recognized Expert Top Contributor
I don't understand your question; but I am pretty sure your piece of code will fail with a 'headers already sent' error
Aug 16 '10 #2
johny10151981
1,059 Top Contributor
That is the point. This code dont return error. More over it redirected by browser perfectly.

this is the out put i get from a small http client i have made

HTTP/1.1 302 Found
Date: Mon, 16 Aug 2010 08:49:57 GMT
Server: Apache/2.2.11 (Win32) PHP/5.2.8
X-Powered-By: PHP/5.2.8
Location: request.php
Content-Length: 37
Connection: close
Content-Type: text/html

johny
Aug 16 '10 #3
johny10151981
1,059 Top Contributor
I have just made a test


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  echo "I am johny\n"; 
  3.  setcookie("Log_time", time()); //according to my previous knowledge it was not suppose to work
  4. ?>
the output is

HTTP/1.1 200 OK
Date: Mon, 16 Aug 2010 09:06:50 GMT
Server: Apache/2.2.11 (Win32) PHP/5.2.8
X-Powered-By: PHP/5.2.8
Set-Cookie: Log_time=128194 9610
Content-Length: 11
Connection: close
Content-Type: text/html

I am johny


now i can guess its a version issue. Now PHP do not send data directly to client. First it create output then send it to client. that is why it does not create any warning. But I can guess older version make this warning.
Aug 16 '10 #4
code green
1,726 Recognized Expert Top Contributor
I thought this was only possible with output buffering turned on.
Is it turned on by default in your version?
Take a look at the php.ini file
Aug 16 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
for the client it doesn’t matter if there is content or not. the Location header directive just states that the the client has to load the specified URI.
Aug 16 '10 #6
johny10151981
1,059 Top Contributor
@code_green
in that case this is the fact. In my case output buffering is on.
I didnt change the configuration. it was default

Directive Local Value Master Value
output_bufferin g 4096 4096


I got my answer, I think.

@Dormilich:
The entire issue started while i was answering one persons question about header warning. When I tested it in my page with Location directive it was not making any warning. So I made a c code to check what server give to client. Then i figured out that the header part is in header part even though i already have sent the out data. So I was confused how it work. :) now i got my answer
Aug 16 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
6239
by: Jeff | last post by:
I've been able to find this question on a Google group search but not the answer. Plus I'm a late convert to php transferring over from ASP. I hope this isn't too many strikes against me. When I issue a "header(Location:/myscript.php?key1=value1&key2=value2);" the redirect happens just fine but the url in the address field keeps the...
6
18258
by: Filth | last post by:
Hi this is probably very easy to sort but I want to do the following:- header( "Location: subscribe_form.php?name='.$_GET.'&email='.$_GET.'"); but this pulls up the error:- Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
10
5613
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',...
2
2405
by: Stephen Preston | last post by:
I have a split frame which holds in the upper part a php file with a header location function, which opens a new file (lower.php). I'm trying to get the header function to open lower.php in the lower half of the frame, header("Location: lower.php TARGET='lowframe') with out the Target setting, it opens lower.php in the upper part (ie it...
23
3596
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...
2
8813
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
5435
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.
4
10411
by: geshan | last post by:
In php5 I am not able to use include funciton and header("location:""" together please help.
8
39739
by: pedalpete | last post by:
I thought this should be simple, but i can't seem to get it to work. I'm trying to do a simple redirect to a page, but need to pass a variable. I've tried a few things, but nothing seems to work. here's what I've tried header('Location: edit.php?sid=$sid');
0
7464
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...
0
7656
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. ...
1
7413
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...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5323
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...
0
3449
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...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.