473,543 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Header

AJ
hi all

I'm having trouble getting something simple working and can't see why.

This is the code I'm running:

<?php if ($row_Recordset 1['type']=="agent"){

header("Locatio n: agentindex.php" );
echo "AGENT";
exit;
}

else
{
header("Locatio n: llindex.php");
echo "LANDLORD";
exit;
}

?>
Jul 17 '05 #1
3 1589
AJ wrote:
I'm having trouble getting something simple working and can't see why. Are you getting errors? If so, what are they?
header("Locatio n: agentindex.php" ); This will force most browsers to redirect immediately. You should also
specify the full URI, rather than the file name alone.
echo "AGENT"; This may never be executed, or rather may never be seen inthe browser as
it will be replaced with the page to which you have just redirected.
header("Locatio n: llindex.php");
echo "LANDLORD";

Likewise

If you are getting headers already sent errors, you script is outputting
something before the location call (even one white space character).

Check the manual for Output control and for headers:
http://uk2.php.net/manual/en/ref.outcontrol.php
http://uk2.php.net/header

Hope this helps, regards,

Andy
Jul 17 '05 #2
AJ

"Andy Barfield" <ab**********@y ahoo.com> wrote in message
news:q6******** ************@ni ldram.net...
AJ wrote:
I'm having trouble getting something simple working and can't see why.

Are you getting errors? If so, what are they?


I've actually managed to sort it. I've found two things to watch out for:

1. Probably obvious, but it wasn't to me. I'd put the PHP with the header
information inside the <BODY> of the page
2. It would appear that any white space after the header call messes things
up. Even a space after the ; will cause it not to work

Does that sound feasible?

Andy
Jul 17 '05 #3
Sorry - been away for a couple of days, didn't see your reply.

AJ wrote:
1. Probably obvious, but it wasn't to me. I'd put the PHP with the header
information inside the <BODY> of the page Yep, that would do it - the headers must be sent before any other output
to the browser, even a space before the <?php tag will stop it working
and give you a "headers already sent" error.
2. It would appear that any white space after the header call messes things
up. Even a space after the ; will cause it not to work

Not seen that happen before. I often use the Location header in an
if-else block like

if(!something)
{
header("Locatio n: http://somewhere.else/");
exit;
}
else
{
echo "I have not reditected you";
}

Regards,

Andy
Jul 17 '05 #4

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

Similar topics

6
3417
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...
11
2734
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do understand the objective. This example may represent an interface in need of a bit of refactoring, but it goes to demonstrate the basic idea as I...
60
8215
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
18
2724
by: John Smith | last post by:
Hi all What does the group think of the practise of including one header file from inside another? I have some legacy code where this has been done, and it creates a dependency on a module (collection of files) which are not required, except for one header file's contents. I'd say 'No, header files should be included in the C source,...
6
7061
by: Jason Collins | last post by:
There seems to be an inconsistency (bug?) in the way the Set-Cookie header is handled by the WebHeaderCollection. That is, the values of Set-Cookie, when an Expires is specified, contain the "," character. This seems to be incorrectly parsed during GetValues(). A simple example shows it best (there are 2 .aspx pages and an output): ...
0
3716
by: Dean Hallman | last post by:
Hello, I am developing a BHO that should add a custom HTTP header on a specific domain only. Don't want the header globally, otherwise I could just add a registry key. So, on BEFORENAVIGATE2, I am canceling the current navigation and renavigating with the new custom header using Navigate2. This usually works fine, but in some cases...
4
2466
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code m_Token = null in order to destroy the session token when the user logs out. However, I'm finding that setting class instance to null results in no...
1
24112
by: Shalako | last post by:
I check my error log and see these entries: malformed header from script. Bad header= Missing gauge reports are ind: padata.pl /perl/pema/padata.pl did not send an HTTP header malformed header from script. Bad header= : padata.pl /perl/pema/padata.pl did not send an HTTP header malformed header from script. Bad header= Missing...
5
1959
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works very well. however, i tried to translate it to c# and i'm getting the header inserting itself over the first datarows and inserting blank rows at the bottom. i can post the code if necessary for the C# but it basicly mirrors the vb.net -- (i''ll be asking a lot...
30
1661
by: xiao | last post by:
HI~ EVERY ONE~ I have a small program here, when I tried to compile it , it always reminds that arrary.c: In function `main': arrary.c:39: error: `header' undeclared (first use in this function) arrary.c:39: error: (Each undeclared identifier is reported only once arrary.c:39: error: for each function it appears in.) Why is that ? I...
0
7412
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...
1
7356
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
7697
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
5889
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
5285
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
3394
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...
1
1830
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
1
979
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
648
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.