redirect with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

redirect with php

Post by nite4000 »

I am trying to have a page redirect if a setting is enabled. i have tried the meta refresh but the page keeps refreshing over and over if i could stop it after 1 time it would work. I also have tried header but i get a header error as always

Does anyone have any ideas how to use one of these to make it work.?

here is the code i am using

Code: Select all

if($sign['random_referral']=='1') { 

$sql = "SELECT username FROM members ORDER BY RAND() LIMIT 1"; 
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
$var1 = $row['username'];
header("Location: signup.php?ref='.$var1.'");
exit;
}
anyhelp would be great
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: redirect with php

Post by Christopher »

What is the header error? Usually some output, often whitespace, has been output before the call to header().
(#10850)
Post Reply