php redirection

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

p3x
New php-forum User
New php-forum User
Posts: 17
Joined: Mon Mar 03, 2003 10:53 am

php redirection

Postby p3x » Mon Mar 03, 2003 11:00 am

Hello, I have the following problem. I have an index.php page and when people visit the page I want to automatically redirect them to index.php?var=1
I tried to do this with the header location method, like this:
<?php
header("Location: http://www.bleh.com/index.php?var=1");
?>

I inserted this code at the top of my page, but it didn't work. It DID work when I tried something like this:
<?php
header("Location: http://www.google.com");
?>
then the redirection DID work.

Im not sure what I'm doing wrong and I hope someone can help me. Thanks in advance :)

P3x

User avatar
pootergeist
New php-forum User
New php-forum User
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK
Contact:

Postby pootergeist » Mon Mar 03, 2003 1:07 pm

why not just set the var to 1 if it isn't set?

if(!isset($_GET['var']))
{
$_GET['var'] = 1;
}

rather than redirecting to do that?

p3x
New php-forum User
New php-forum User
Posts: 17
Joined: Mon Mar 03, 2003 10:53 am

thanks :) that worked

Postby p3x » Tue Mar 04, 2003 2:27 am

Thanks man, it worked. But I wonder why it doesn't work with the redirection...strange. Anyway, it's working now, so I shouldn't fret on it.

Cheers

P3x.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron