public function getEmployeeId() {
if (!isset($_SESSION["email"]) || !isset($_SESSION["passwrd"])) {
header("Location:index.php");
// Cannot Access this page without Login.
}
if (empty($_POST)){
$_SESSION['ids'] = "";
$query = mysqli_query($this->connection, "SELECT MAX(EmployeeId) AS EmployeeId FROM employees") or die("Query execution failed: " . mysqli_error());
while ($row = $query->fetch_assoc()) {
// Push the id to the array.
$_SESSION['ids'] = $row["EmployeeId"];
}
}
}
上面的代码段带来了数据库中最新注册的员工ID。 ------------------------> --------------------
public function updateSalary(){
if (!isset($_SESSION["email"]) || !isset($_SESSION["passwrd"])) {
header("Location:index.php");
// This code Snippet ensures that in order to access this page Employee needs to be Login.
}
$EmployeeID = (isset($_GET['EmployeeId']) ? $_GET['EmployeeId'] : '');
$query = mysqli_query($this->connection, "SELECT * FROM salary WHERE EmployeeId= '" . $EmployeeID . "'") or die("Query execution failed: " . mysqli_error());
while ($row = $query->fetch_assoc()){
// Push the id to the array
$_SESSION['eids'] = $row["EmployeeId"];
$_SESSION['salry'] = $row["Salary"];
if ($_SESSION['ids']) {
$_SESSION['ids'] = "";
}
}
上面的代码片段是我更新每条记录的更新功能。我在上面的html表单中包含了上述功能。
问题是:由于我的插入和更新表单相同,因此if语句中的会话值在文本框中回显,否则即使会话未设置,部分也不起作用如果是部分,我该怎么办?请参阅以下代码
这是值属性:
<td>
<input type="number" name="EmployeeId" placeholder="EmployeeId" value="<?php if (isset($_SESSION["ids"])){echo $id_salaries;}else{echo $emp_id;} ?>" id="EmployeeId" autocomplete="off" class="form-control" readonly>
</td>
答案 0 :(得分:1)
这不是会话未设置NavigationEventArgs.Parameter
这是您为会话分配空字符串值。会话未设置应为$_SESSION['ids'] = "";