未定义索引:带有$ GLOBAL变量的类型

时间:2019-03-24 05:33:24

标签: php global undefined-index

我设置了一个超级全局变量$GLOBALS['Type']="JobSeeker",但是在另一个文件中,运行程序获取Undefined Index:Type时无法访问该变量。

Page1.php

$con = mysqli_connect("localhost","root","","job1");
// Specify the query to execute
$sql = "select * from JobSeeker_registration where JobSeekerId='".$ID."'  ";
// Execute query
$result = mysqli_query($con,$sql);
// Loop through each records 
$row = mysqli_fetch_array($result);


$GLOBALS['Name']=$row['JobSeekerName'];

$GLOBALS['Email']=$row['Email'];

$GLOBALS['Approval']="Confirm";

$GLOBALS['Type']="JobSeeker";
.
.
.
.
include '../Mailing/MailSending.php';

MailSending.php:

if($GLOBALS['Type']=="JobSeeker")  //Here is Error:-Undefined Index of Type
{
    if($GLOBALS['Approval']=="Pending")
    {
        $UserName=$GLOBALS['Email'];
        $mail->addAddress($UserName, $GLOBALS['Name']);
        $mail->Subject = 'Registration Mail';
        $mail->msgHTML(file_get_contents("Mailing/Pending.html"), __DIR__);
        $GLOBALS['Email']="";
        $GLOBALS['Type']="";
        $GLOBALS['Name']="";
        $GLOBALS['Approval']="";
    }
    elseif ($GLOBALS['Approval']=="Confirm") 
    {
        $UserName=$GLOBALS['Email'];
        $mail->addAddress($UserName, $GLOBALS['Name']);
        $mail->Subject = 'Registration Confirmation Mail';
        $mail->msgHTML(file_get_contents("Mailing/Confirm.html"), __DIR__);
        $GLOBALS['Email']="";
        $GLOBALS['Type']="";
        $GLOBALS['Name']="";
        $GLOBALS['Approval']="";
    }
}

我尝试使用不同的名称,但没有任何解决方法。

0 个答案:

没有答案