2012-04-18 31 views
2

... if语句的条件满足了?如何使用PHP自动更改页面如果

我有一些代码添加数据到数据库,如果满足某些条件,数据添加后我希望页面重定向到另一个页面?我怎样才能做到这一点?

+0

'header('location:/page2.php');'' – Rufinus 2012-04-18 11:34:23

回答

3

使用if-else条件。你可以使用PHP的header()。

if(/* Your conditions */){ 
// redirect if fulfilled 
header("Location:nxtpage.php"); 
}else{ 
//some another operation you want 
} 
2

你建议立即进行删除使用头PHP函数

<?php 

    //some conditions 

    header("Location: http://www.example.com/"); 

?> 
1

试试这个代码

$query ="insert into test values (1,'test')"; 

if(mysql_query($query) == true) 
{ 
    header('location:index.php'); 
    exit(); 
} 
else 
{ 
    echo " insert failed"; 
} 
相关问题