For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2008 > What is wrong?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What is wrong?
Zach

2007-12-31, 7:00 pm


The code below should redirect the user to another page, but doesn't.
What is wrong?
Zach

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Under reconstruction</title>
</head>
<body>
<?php
// Redirect the user to the welcome page!
header ('Location: www.aaa.yy/index.html/');
exit();
?>
</body>
</html>
Janwillem Borleffs

2007-12-31, 7:00 pm

Zach wrote:
> The code below should redirect the user to another page, but doesn't.
> What is wrong?
>


The header function can only be applied without previous output. In other
words, the page should start with the function call and exit immediately.

See: http://www.php.net/header


JW


Cujo

2007-12-31, 7:00 pm

Zach wrote:

> The code below should redirect the user to another page, but doesn't.
> What is wrong?


a) You can't send an HTTP header AFTER any content has been displayed
(unless you work around this by enabling output buffering).

b) Location: demands a full URL. Ie, it should begin with "http://".

regards, f.
Zach

2007-12-31, 7:00 pm

do you mean only

<?php
// some code
?>

and nothing else?

Zach

Zach wrote:
>
> The code below should redirect the user to another page, but doesn't.
> What is wrong?
> Zach
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
> <title>Under reconstruction</title>
> </head>
> <body>
> <?php
> // Redirect the user to the welcome page!
> header ('Location: www.aaa.yy/index.html/');
> exit();
> ?>
> </body>
> </html>

Guillaume BASSINET

2007-12-31, 7:00 pm

Zach a écrit :[color=darkred]
> do you mean only
>
> <?php
> // some code
> ?>
>
> and nothing else?
>
> Zach
>
> Zach wrote:

yep! only php!!!
Zach

2007-12-31, 7:00 pm

Thanks mate,
Zach

Guillaume BASSINET wrote:
> Zach a écrit :
>
> yep! only php!!!

Zach

2007-12-31, 7:00 pm

How do I deal with this error??

This error (HTTP 403 Forbidden) means that Internet Explorer was able to
connect to the website, but it does not have permission to view the webpage.

Zach.


Zach wrote:[color=darkred]
> Thanks mate,
> Zach
>
> Guillaume BASSINET wrote:
Cujo

2007-12-31, 7:00 pm

Janwillem Borleffs wrote:

> The header function can only be applied without previous output. In other
> words, the page should start with the function call and exit immediately.



Not really.

What happens AFTER the call is irrelevant as it never gets executed.

What happens BEFORE the call can be ANYTHING provided it doesen't send
ANY output to the browser.

regards, f.
Cujo

2007-12-31, 7:00 pm

Zach wrote:

> How do I deal with this error??


Did you pass a FULL URL in header ('Location: ') ?

A full URL starts with "http://"

regards, f.
Zach

2007-12-31, 7:00 pm

I had that already. So not the cause.
Zach

Cujo wrote:
> Zach wrote:
>
>
> Did you pass a FULL URL in header ('Location: ') ?
>
> A full URL starts with "http://"
>
> regards, f.

www.j2be.com

2008-01-01, 7:59 am

"Zach" <xx@xx.xx> ha scritto nel messaggio
news:47790757$0$24413$5fc3050@news.tiscali.nl...
>
> The code below should redirect the user to another page, but doesn't. What
> is wrong?
> Zach
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
> <title>Under reconstruction</title>
> </head>
> <body>
> <?php
> // Redirect the user to the welcome page!
> header ('Location: www.aaa.yy/index.html/');
> exit();
> ?>
> </body>
> </html>


The header ('Location: www.aaa.yy/index.html/'); must be on the top of all
the code before any output.
You can use a meta refresh in the html to redirect without fancy headers.


Cujo

2008-01-01, 7:01 pm

Zach wrote:

> I had that already. So not the cause.


Copy and paste the "Location" you are redirecting to in your browser. If
you get the same error, the problem is obviously not related to php.

Check your web server configuration.

regards, f.
Zach

2008-01-01, 7:01 pm

Ok I'll try that.
Zach

www.j2be.com wrote:
>snipped
> You can use a meta refresh in the html to redirect without fancy headers.
>
>

Zach

2008-01-01, 7:01 pm

I don't think I can reconfigure setings at the ISP.
The address is OK.

Thanks,
Zach.




Cujo wrote:
> Zach wrote:
>
>
> Copy and paste the "Location" you are redirecting to in your browser. If
> you get the same error, the problem is obviously not related to php.
>
> Check your web server configuration.
>
> regards, f.

Michael Fesser

2008-01-01, 7:01 pm

..oO("www.j2be.com" <info@[nospam[j2be.com> )

>The header ('Location: www.aaa.yy/index.html/'); must be on the top of all
>the code before any output.
>You can use a meta refresh in the html to redirect without fancy headers.


Of course you don't want to do that. The HTTP header is the way to go.

Micha
Cujo

2008-01-01, 7:01 pm

www.j2be.com wrote:

> You can use a meta refresh in the html to redirect without fancy headers.


Bleah !

regards, f.
Cujo

2008-01-01, 7:01 pm

Zach wrote:

> I don't think I can reconfigure setings at the ISP.
> The address is OK.


You mean: The following:

header ('location: http://somewhere.com');

gives you a "HTTP 403 Forbidden", whereas typing
the *exact* (including trailing slashes, etc.) same url
paste into your browser does *not* ?

Are you sure ? I can't see how it could be possible ...


What happens if you do:

header ('location: http://www.google.com');

Does your page redirect correctly to google ?

regards, f.
Zach

2008-01-02, 7:59 am

I have done the alternative thing

<meta http-equiv="refresh" content="0;url=http://www.blabla.blo">

and that does work fine.
Many thanks all.
Zach.

Cujo wrote:
> Zach wrote:
>
>
> You mean: The following:
>
> header ('location: http://somewhere.com');
>
> gives you a "HTTP 403 Forbidden", whereas typing
> the *exact* (including trailing slashes, etc.) same url
> paste into your browser does *not* ?
>
> Are you sure ? I can't see how it could be possible ...
>
>
> What happens if you do:
>
> header ('location: http://www.google.com');
>
> Does your page redirect correctly to google ?
>
> regards, f.

Michael Fesser

2008-01-02, 7:00 pm

..oO(Zach)

>I have done the alternative thing
>
><meta http-equiv="refresh" content="0;url=http://www.blabla.blo">
>
>and that does work fine.


It doesn't

Use standard redirects: don't break the back button!
http://www.w3.org/QA/Tips/reback

Micha
Zach

2008-01-04, 7:01 pm

In-Reply-To: <tgqnn3h37j9u38qt3np635bv91kq9rgo04@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <477ec209$0$24403$5fc3050@news.tiscali.nl>
Organization: Tiscali
NNTP-Posting-Date: 05 Jan 2008 00:32:25 CET
NNTP-Posting-Host: 46108165.news.tiscali.nl
X-Trace: DXC=XNhJ;GDmTaHeV;>Kc]gB5GB>BklU>=_UEJGBYkgPmY@BXl;G=Bo7RkA:I>fI8h_4]M^Pd@jdLB@eA
X-Complaints-To: abuse@tiscali.nl
Bytes: 1862
Xref: number1.nntp.dca.giganews.com alt.comp.lang.php:43362

oO(h dear) to think I was happy that I finally got it to work...
Zach.

Michael Fesser wrote:
> .oO(Zach)
>
>
> It doesn't
>
> Use standard redirects: don't break the back button!
> http://www.w3.org/QA/Tips/reback
>
> Micha

Dezen

2008-01-06, 1:53 pm

Thousands of MP3s for free at http://mp3files4free.com/

Our new hits:
"Boney James - What Are You Doing New Year's Eve" free mp3 download
"Hans Zimmer - Climb On (A Back That's Strong) - Shawn Colvin" free mp3 download
"Ibrahim Ferrer - Deuda" free mp3 download
"Ideal J - J'ai Mal Au Coeur" free mp3 download
"Neuropa - The Only One (Sequencia Remix)" free mp3 download
"Def Leppard - Day After Day" free mp3 download
"Ani DiFranco - Both Hands" free mp3 download
"Moscow Grooves Institute - Liqud-Balance" free mp3 download
"Logos - La Force De La Terre" free mp3 download
"Extol - Human Frailie's Grave" free mp3 download
"Demis Roussos - Stormy Weather" free mp3 download
"Miles Davis - Sequence Voiture (take 2)" free mp3 download
"Electronic - Various Artists - Fio Maravilha (Tania Maria)" free mp3 download
"Hed Kandi - Lets Be Young - Quentin Harris" free mp3 download
"Despina Vandi - Tis Kardia Mou Giatreia" free mp3 download
"Alan Lomax - the laird o'drum [lucy stewart]" free mp3 download
"New Age - Various Artists - Inspiration (Deleerious 3)" free mp3 download
"The Bee Gees - I Surrender" free mp3 download
"Cemetery Of Scream - The Secret Window" free mp3 download
"Katharsis - Painlike Paradise" free mp3 download
"Gloria Trevi - El ultimo beso" free mp3 download
"Soundtrack - Various Artists - red_queen (Resident Evil)" free mp3 download
"Basic Element - Talk To Me" free mp3 download
"Hearts of Space - Union" free mp3 download
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com