Php 回音另一页

Php 回音另一页,php,Php,我想在code.php文件中显示消息 if( $e->getCode() == 23000) { $message = 'Username already exists'; } 在 如果getcode=2000,我想重定向到index.php并回显消息 我如何使它工作 感谢使用echo 在code.php中 if( $e->getCode() == 23000) { $message = 'Username already exist

我想在code.php文件中显示消息

 if( $e->getCode() == 23000)
    {
        $message = 'Username already exists';
    }

如果getcode=2000,我想重定向到index.php并回显消息

我如何使它工作


感谢使用
echo

在code.php中

 if( $e->getCode() == 23000)
 {
     $message = 'Username already exists';
     header("Location: index.php?message=".$message);
 }
在index.php中

if(isset($_GET['message'])){
    $message = $_GET['message'];
} else {
    $message = "";
}
 <p><?php echo $message ?></p>
if(isset($\u GET['message'])){
$message=$_GET['message'];
}否则{
$message=“”;
}


如果您的页面扩展名为.html,那么您唯一的选择就是向PHP页面发出ajax请求。要使用
PHP
代码,您的文件必须位于
.PHP
扩展名中。@NiranjanNRaju我已将其更改为index.phpjack,您有两个文件吗?请详细说明您想要实现的目标。@DarkAnavger是2个文件我有2个文件code.php和index.php。消息是code.php,如果($e->getCode()==23000),则中的将重定向到index.php并回显消息