Hi

I have an if statement within which i have to implement the redirection to another form or index.php, when i implement that it gives me an error that it already have the "Header", to solve this if i add the die(); it dies and does not call the next form or anything i.e. does not get redirected to anything. I would like to know how to redirect to another form. Thanks for any help in advance.

You must do a redirect before sending out any HTML to the browser. This includes whitespace at the top of your file.

Thanks a lot, but i tried it and it did not work

Apart from this, the problem is that, the new page has to be loaded i.e. the redirection has to be done according to the if statement i.e. under certain conditions, so how should i do this before as you have said

any direction towards solution would be highly appreciated

Thanks and regards

Sarah

Post the code for the page so we can take a peek.

Member Avatar for Rhyan

Thanks a lot, but i tried it and it did not work

Apart from this, the problem is that, the new page has to be loaded i.e. the redirection has to be done according to the if statement i.e. under certain conditions, so how should i do this before as you have said

any direction towards solution would be highly appreciated

Thanks and regards

Sarah

Your code should look like this in order to work:

/*!DO NOT INSERT <HTML DTD.... here>!*/
<?php
  if ( rule 1)
   {
    header ("Location: http://url1....");
   }
else {
   header ("Location: http://url2...."); 
  }
?>

/*You may insert html dtd and content here, however it will always be skipped because of the rule defined above. NOTE PHP SHOULD BE INSERTED BEFORE <HTML> OPENING TAG IN ORDER REDIRECTION TO WORK.*/

Have you use the same include file in both the pages like anything session files or anything like that?

try this

if(statement)
{
echo "<html><head>
                        <meta http-equiv='refresh' content='0;url=your_page_link.php'>
                        </head></html>";
}
else
{
echo "<html><head>
                        <meta http-equiv='refresh' content='0;url=your_page_link.php'>
                        </head></html>";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.