Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined index for updating database
    text
    copied!<p>i cant seem to find what is wrong with my code. </p> <p>i just want to have a not bias opinion about since for me its perfect well its not xD. </p> <pre><code>&lt;?php require("common.php"); if(empty($_SESSION['user'])) { header("Location: login.php"); die("Redirecting to login.php"); } if(!empty($_POST)) { if($_POST['eID'] != $_SESSION['user']['eID']) { $query = " SELECT 1 FROM users WHERE eID = :eID "; $query_params = array( ':eID' =&gt; $_POST['eID'] ); try { $stmt = $db-&gt;prepare($query); $result = $stmt-&gt;execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex-&gt;getMessage()); } $row = $stmt-&gt;fetch(); if($row) { die("This employee ID is already registered"); } } if(!empty($_POST['password'])) { $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647)); $password = hash('sha256', $_POST['password'] . $salt); for($round = 0; $round &lt; 65536; $round++) { $password = hash('sha256', $password . $salt); } } else { $password = null; $salt = null; } $query_params = array( ':eID' =&gt; $_POST['eID'], ':user_id' =&gt; $_SESSION['user']['id'], ); if($password !== null) { $query_params[':password'] = $password; $query_params[':salt'] = $salt; } $query = " UPDATE users SET eID = :eID "; if($password !== null) { $query .= " , password = :password , salt = :salt "; } $query .= " WHERE id = :user_id "; try { $stmt = $db-&gt;prepare($query); $result = $stmt-&gt;execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex-&gt;getMessage()); } $_SESSION['user']['eID'] = $_POST['eID']; header("Location: private.php"); die("Redirecting to private.php"); } ?&gt; &lt;h1&gt;Edit Account&lt;/h1&gt; &lt;form action="edit_account.php" method="post"&gt; Username:&lt;br /&gt; &lt;b&gt;&lt;?php echo htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/b&gt; &lt;br /&gt;&lt;br /&gt; EmployeeID:&lt;br /&gt; &lt;input type="text" name="eID" value="&lt;?php echo htmlentities($_POST['eID'], ENT_QUOTES, 'UTF-8'); ?&gt;" /&gt; &lt;br /&gt;&lt;br /&gt; Password:&lt;br /&gt; &lt;input type="password" name="password" value="" /&gt;&lt;br /&gt; &lt;i&gt;(leave blank if you do not want to change your password)&lt;/i&gt; &lt;br /&gt;&lt;br /&gt; &lt;input type="submit" value="Update Account" /&gt; &lt;/form&gt; </code></pre> <p>its a code wherein it will alter the data in my database.it seems that i have an error with "eID"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload