我在删除员工时收到错误“Undefined index: Msg in Employee.php”。我试图显示来自employeedb.php 的会话值。这是我的employee.php。这里我试图在 div“divGuestRegisterContainer”中显示会话消息
<?php
require_once("includes.php");
<div id="divGuestRegisterContainer" >
<b>
<?php
if($_SESSION["Msg"]!="")
{
?>
<ul>
<li>
<b><?php
echo $_SESSION["Msg"];
?>
</b>
</li>
</ul>
<?php
$_SESSION["Msg"]="";
}
?>
</b>
<ul>
<li>
<span style="width:120px;">Employee Name :</span>
<input type="text" name="txt_empname" id="txt_empname" class="textbox" value="<?php echo $emp_name;?>" />
</li>
<li >
<input type='button' id='btnDelete' name='btnDelete' class='button' value='Delete' onclick='deleteEmployee()' style='margin-left:10px;width:85px;display:inline' />
</li>
</ul>
</div>
?>
我将 $_SESSION["Msg"] 值从employeedb.php 传递给employee.php 这是我的employeedb.php
<?php
require_once("includes.php");
$genObj=new general();
$type=$_GET["type"];
$emp_id=$_POST["HFEmpID"];
if($type=="delete")
{
mysql_query("UPDATE employee SET del_flag=1 WHERE emp_id=".$emp_id."");
$_SESSION["Msg"]="Employee details deleted successfully!";
}
header( 'Location:Employee.php');
?>
当我点击删除按钮时,正在调用这个 javascript 函数,这是我的 javascript 函数。
function deleteEmployee()
{
var del = confirm("Are you sure you want to delete this Employee?");
if (del == true)
{
document.forms[0].action="employeeDB.php?type=delete";
document.forms[0].submit();
}
else
{
document.forms[0].action="employeeDB.php";
}
}
这是我的includes.php,我已经开始了会话
<?php
session_start();
ob_start();
//Session Starts
require_once("config/config.php");
require_once("config/dbcon/dbcon.php");
require_once("classes/csGeneral.php");
require_once("classes/csPager.php");
require_once("classes/csImageFunctions.php");
require_once("classes/striptag.php");
/* $_SESSION["returnURL"]=$_SERVER['HTTP_REFERER']; */
$genCheckUser=new general();
$genCheckUser->getUserIDCookie();
?>