Page 1 of 1

redirect url

Posted: Thu Nov 24, 2005 3:36 am
by jaylin
i want to redirect a page after a checking.
for e.g

if (a == a)
// redirect to http://www.abc.com
else
//redirect to http://www.bbb.com

regards,

Posted: Thu Nov 24, 2005 3:46 am
by Grim...

Code: Select all

<?
if ($a == $a)
{
    header("location: thispage.php");
    exit;
}
else
{
    header("location: thisotherpage.php");
    exit;
}

Posted: Thu Nov 24, 2005 4:22 am
by jaylin
i goot this error
Warning: Cannot modify header information - headers already sent by (output started at c:\Inetpub\wwwroot\toniwin\automobile.php:4) in c:\Inetpub\wwwroot\toniwin\automobile.php on line 32

Posted: Thu Nov 24, 2005 10:33 am
by twigletmac
Have a look at this thread:
viewtopic.php?t=1157

Mac

Posted: Sun Nov 27, 2005 10:11 pm
by jaylin
i have seen the post. but, i have no idea to solve my problem. i think it is better to post my code and let expert solve the problem for me.

Code: Select all

if (isset($_REQUEST['action']) && $_REQUEST['action']=='submitted')
    {
        if (isset($_REQUEST['memberid']))
        {
            $link =  mysql_connect('mydatabase','myuser','mypassword');
            if (!$link)
                echo 'Can\'t open the database';
            else
            {
                $db = mysql_select_db('mydbase');
                if (!$db)
                {
                  echo 'DataBase Error : ' . mysql_error();
                }
                $sql = "SELECT * FROM member WHERE memberID=" . $_REQUEST['memberid'];
                $query = mysql_query($sql);
                $num_row = mysql_num_rows($query);
                if ($num_row >0 )
                {
    header("Location: thispage.php");
                 }
                else
                    echo 'get out of here';
            }

plz help me.
twigletmac wrote:Have a look at this thread:
viewtopic.php?t=1157

Mac

Posted: Sun Nov 27, 2005 10:23 pm
by shiznatix
there has to be more code above that wether it be html or anything. if you output ANYTHING to the browser before you call header() you will get that error. post all the code before that

Posted: Sun Nov 27, 2005 10:26 pm
by jaylin
thz for all. now i fixed it. :lol: :lol: :lol: :lol: