Note that there are some explanatory texts on larger screens.

plurals
  1. PORow won't update in database
    text
    copied!<p>I'm making a community site thing.</p> <p>I'm currently making the option to change your password.</p> <p>But, when I try to use it, it won't work..</p> <p>Why is this? How do I fix it?</p> <p>My code:</p> <p><strong>Settings.php</strong> (Where I change the pass)</p> <p><strong>PHP:</strong></p> <pre><code>&lt;?php error_reporting(E_ALL); include_once('includes/connection.php'); include_once('includes/user.php'); if(isset($_SESSION['logged_in'])){ if(isset($_POST['oldpass']) and isset($_POST['newpass'])){ $name = $_COOKIE['name']; $oldpass = md5($_POST['oldpass']); $newpass = md5($_POST['newpass']); $query = $pdo-&gt;prepare("SELECT * FROM users WHERE username=? AND password=?"); $query-&gt;bindValue(1, $name); $query-&gt;bindValue(2, $oldpass); $query-&gt;execute(); $num = $query-&gt;rowCount(); if($num==1){ $query = $pdo-&gt;prepare("UPDATE users SET password=? WHERE username=?"); $query-&gt;bindValue(1, $newpass); $query-&gt;bindValue(2, $name); $result = $query-&gt;execute(); if($result==1){ header('Location: logout.php'); }else{ echo "Something went wrong."; } } } } ?&gt; </code></pre> <p><strong>HTML:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;MackNet&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="assets/style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="main"&gt; &lt;?php $name = $_COOKIE['name']; $pass = $_COOKIE['pass']; $user = new User(); $row = $user-&gt;fetch_all($name, $pass); ?&gt; &lt;div id="toolbar"&gt; &lt;?php echo " &lt;a href='main.php'&gt;Home&lt;/a&gt; "; echo " &lt;a href='logout.php'&gt;Logout&lt;/a&gt; "; echo " &lt;a href='settings.php'&gt;Settings&lt;/a&gt; "; if($row['group'] == 2){ echo " &lt;a href='users.php'&gt;Manage Users&lt;/a&gt; "; } ?&gt; &lt;hr&gt; &lt;/div&gt; &lt;form action="settings.php" method="POST"&gt; &lt;input type="password" name="oldpass" placeholder="Old Password"&gt; &lt;input type="password" name="newpass" placeholder="New Password"&gt; &lt;input type="submit" value="Change password"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If you need any more code, tell me.</p> <p>Thanks // Mackan90095</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