# Redirection in PHP

**URL:** <https://forum.kirupa.com/t/redirection-in-php/10055>\
**Category:** programming\
**Created:** [December 23, 2002, 2:57pm UTC](https://forum.kirupa.com/t/redirection-in-php/10055 "2002-12-23T14:57:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martystudio](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@martystudio](https://forum.kirupa.com/u/martystudio)\
**Post date:** [December 23, 2002, 2:57pm UTC](https://forum.kirupa.com/t/redirection-in-php/10055/1 "2002-12-23T14:57:20Z")

</div>

I have this code

```php
if (is_null($_POST['name']) == TRUE) {
header("Location: http://www.martystudio.com/index.php?error=101&from=home");
}
print $name;

```

it works fine, but when iit is supposed to redirect it wont, i need to find out why and find the script that works:

Note, for some reason the link looks funny when im posting

[COLOR=silver][SIZE=1]Edited by h88 - fixed code[/SIZE][/COLOR]

---

<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:** [December 24, 2002, 3:32pm UTC](https://forum.kirupa.com/t/redirection-in-php/10055/2 "2002-12-24T15:32:09Z")

</div>

Are you using GET or POST to post your variables?

The code is working fine…

---

<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:** [December 25, 2002, 6:41pm UTC](https://forum.kirupa.com/t/redirection-in-php/10055/3 "2002-12-25T18:41:08Z")

</div>

you might be wanting to use output buffering too when redirecting.  
ob\_start()  
ob\_end\_clean()  
ob\_end\_flush()

that is so you wont be getting any errors about headers already sent
