php - if else construct issue in value attribute of html -


 public function getemployeeid() {         if (!isset($_session["email"]) || !isset($_session["passwrd"])) {             header("location:index.php");             // cannot access page without login.         }         if (empty($_post)){             $_session['ids'] = "";             $query = mysqli_query($this->connection, "select max(employeeid) employeeid employees") or die("query execution failed: " . mysqli_error());             while ($row = $query->fetch_assoc()) {                 // push id array.                 $_session['ids'] = $row["employeeid"];             }         }     } 

the above code snippet bring latest registered employee id database. ------------------------>--------------------

public function updatesalary(){         if (!isset($_session["email"]) || !isset($_session["passwrd"])) {             header("location:index.php");             // code snippet ensures in order access page employee needs login.         }         $employeeid = (isset($_get['employeeid']) ? $_get['employeeid'] : '');         $query = mysqli_query($this->connection, "select * salary employeeid= '" . $employeeid . "'") or die("query execution failed: " . mysqli_error());         while ($row = $query->fetch_assoc()){             // push id array             $_session['eids'] = $row["employeeid"];             $_session['salry'] = $row["salary"];             if ($_session['ids']) {             $_session['ids'] = "";             }         } 

the above code snippet update function update each record. , have included both above function in html form @ top.

the problem : insertion , updation form same, session value in if statement echoed in text box , else part not work if session unset in if part, should ? see below code

here value attribute :

 <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>   

this not session unset $_session['ids'] = ""; assigning empty string value session . session unset should unset($_session['ids'])


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -