# Header ("location (...) ");

**URL:** https://forum.kirupa.com/t/header-location/22542
**Category:** programming
**Created:** [June 5, 2003, 8:39am UTC](https://forum.kirupa.com/t/header-location/22542 "2003-06-05T08:39:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Drunken](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@Drunken](https://forum.kirupa.com/u/Drunken)
#### Post date: [June 5, 2003, 8:39am UTC](https://forum.kirupa.com/t/header-location/22542/1 "2003-06-05T08:39:29Z")

</div>

hy!

I have problem with the function header. I think is because the php version, because I am testing in home server by using php 4.3, but when i upload for the server that are using php 4.0.6 the headers don’t work ☹

```php
header("Location:index.php?accao=login_error");

```

Anda the error:

```php
Warning: Cannot add header information - headers already sent by (output started at /var/www/html/apie/klog/admin/teste.php:8) in /var/www/html/apie/klog/admin/teste.php on line 9

```

Help me please :thumb:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 5, 2003, 8:52am UTC](https://forum.kirupa.com/t/header-location/22542/2 "2003-06-05T08:52:17Z")

</div>

I just have solution by using javascript like

```php

<SCRIPT>window.location=\"editar.php produto=$produto\";</SCRIPT>

```

thks lol

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 5, 2003, 1:32pm UTC](https://forum.kirupa.com/t/header-location/22542/3 "2003-06-05T13:32:57Z")

</div>

hey, if you see this could you post the code you are using anyway? Just so we can figure out why it wasn’t working for future reference?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 5, 2003, 2:12pm UTC](https://forum.kirupa.com/t/header-location/22542/4 "2003-06-05T14:12:13Z")

</div>

Source

print (“Error”);  
header(“Location:index.php?accao=login\_error”);

The conclusion for this problem is that in version 4.0.6, if we have a printf before a header, it get error, but in others versions not…

What i did, was clear the printf’s before headears and it works good… maybe isn’t that the real problem but it works without print 😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 5, 2003, 2:23pm UTC](https://forum.kirupa.com/t/header-location/22542/5 "2003-06-05T14:23:04Z")

</div>

might be a problem with that version yea.

Did you have any HTML placed before the header()? cuz yo ucan’t do that.

also, for the print function, there is no need for the ()

just type

```php

print "Error";

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 5, 2003, 3:09pm UTC](https://forum.kirupa.com/t/header-location/22542/6 "2003-06-05T15:09:42Z")

</div>

hmm… i always use print with ()…but ok :P…and i don’t have html before header…

look, i have other problem, i have some sites working with php 4.06 but now i want upgrade de php version in server, but i have the problem with register\_globals, if i ugrade to the last version, that sites that are working with 4.0.6, will brooke because the register globals…and it’s really boring to put $HTTP\_GET\_VARS[]; / $HTTP\_POST\_VARS[]; etc… in all old site…Do u know any solution for this??

danka 😃

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 6, 2003, 12:41am UTC](https://forum.kirupa.com/t/header-location/22542/7 "2003-06-06T00:41:48Z")

</div>

well with the newer version you can put $\_POST[] and $\_GET[] instead of $HTTP\_GET\_VARS[]

or you can just turn global variables on…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 6, 2003, 3:35pm UTC](https://forum.kirupa.com/t/header-location/22542/8 "2003-06-06T15:35:19Z")

</div>

Jubba, thks 😛
