Tuesday, 12 July 2016

how i use of header tag to redirect page in php




I want to redirect the page on the if condition.



this is my html page

















and this is my payment_mode.php page



$i= $_POST['selectmode'];

if($i>1)
{
header("Location : detail.php");


}
else
{
header("Location : home.php");

}

?>



bt it does not redirect the page detail.php and home.php


Answer



Try:



$i= $_POST['selectmode'];

if($i>1)
{
header("Location: detail.php");

exit;

}
else
{
header("Location : home.php");
exit;

}



Also, make sure on this page there is nothing being outputted before your calling the header() function.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...