title: Updating database record with PHP/PDO and mySQL
body: <p>I have a database "Telefoon" with a table "Telefoonnummers". The table has the columns "naam", "number" and "mobiel"</p>
  
  <p>I am trying to make a .php page where I can update a record. I am pretty sure this is right, but somehow nothing changes.</p>
  
  <p>Here you fill in the updated records, and when you click the button it goes to the next page which updates it.</p>
  
  <pre><code>&lt;!DOCTYPE HMTL&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Wijzigen telefoonnummer&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;?php
  
          $record_name = $_GET["naam"];
  
          $user = "root";
          $pass = "root";
  
          $dbh = new PDO(
              'mysql:host=localhost; port=8473; dbname=telefoon',
              $user,
              $pass
          );
  
          $sth = $dbh -&gt; prepare("
  
              SELECT *
              FROM Telefoonnummers
              WHERE naam = :record_name
  
          ");
  
          $sth -&gt; bindValue( ":record_name", $record_name, PDO::PARAM_STR );
  
          $sth -&gt; execute();
  
          $printRecord = $sth -&gt; fetchAll(PDO::FETCH_ASSOC);
  
          /*
          //dit record als array weergeven
          print("&lt;pre&gt;");
          print_r($printRecord);
          print("&lt;/pre&gt;");
          */
  
          //gegevens in variabelen zetten
          $printRecordRecord = $printRecord[0];
          $huidigeNaam = $printRecordRecord["naam"];
          $huidigeNummer = $printRecordRecord["telefoonnummer"];
          $huidigeMobiel = $printRecordRecord["mobiel"];
  
          //niet meer nodig door bovenstaande
          /*
          foreach( $printRecord AS $printRecordIndex =&gt; $printRecordRecord ) {
  
              $huidigeNaam = $printRecordRecord["naam"];
              $huidigeNummer = $printRecordRecord["telefoonnummer"];
              $huidigeMobiel = $printRecordRecord["mobiel"];
  
          }
          */
  
          print("
  
              &lt;form action='wijzig.php' method='POST'&gt;
                  &lt;table&gt;
  
                      &lt;tr&gt;
                          &lt;td bgcolor='green'&gt;&lt;b&gt;Naam&lt;/b&gt;&lt;/td&gt;
                          &lt;td bgcolor='green'&gt;&lt;b&gt;Telefoonnummer&lt;/b&gt;&lt;/td&gt;
                          &lt;td bgcolor='green'&gt;&lt;b&gt;Mobiel&lt;/b&gt;&lt;/td&gt;
                          &lt;td bgcolor='green'&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;&lt;input type='text' name='naam' value='$huidigeNaam' disabled='TRUE' /&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type='text' name='nummer' value='$huidigeNummer' /&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type='text' name='mobiel' value='$huidigeMobiel' /&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type='submit' value='Wijzig' /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                  &lt;/table&gt;
              &lt;/form&gt;
  
          ");
  
      ?&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is the next page which actually changes (at least that's what I want) the record:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Gewijzigd&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;?php
  
          //geupdate gegevens ophalen
          $newNaam = $_POST["naam"];
          $newNumber = $_POST["nummer"];
          $newMobile = $_POST["mobiel"];
  
          //gegevens updaten als ALLES is ingevuld
          if ( ($newNaam != "") &amp;&amp; ($newNumber != "") &amp;&amp; ($newMobile != "") ) {
  
              $user = "root";
              $pass = "root";
  
              $dhb = new PDO(
                  'mysql:host=localhost; port=8473; dbname=telefoon',
                  $user,
                  $pass
              );
  
              $sth = $dbh -&gt; prepare("
  
                  UPDATE Telefoonnummers
                  SET naam = :naam,
                  telefoonnummer = :nummer,
                  mobiel = :mobiel
                  WHERE naam = :naam
  
              ");
  
              $sth -&gt; bindValue( ":naam", $newNaam, PDO::PARAM_STR );
              $sth -&gt; bindValue( ":telefoonnummer", $newNumber, PDO::PARAM_STR );
              $sth -&gt; bindValue( ":mobiel", $newMobile, PDO::PARAM_STR );
  
              $sth -&gt; execute();
  
              $sthCheck = $dbh -&gt; prepare("
  
                  SELECT *
                  FROM Telefoonnummers
                  WHERE naam = :naam
  
              ");
  
              $sthCheck -&gt; bindValue( ":naam", $newNaam, PDO::PARAM_STR );
  
              $sthCheck -&gt; execute();
  
          }
  
      ?&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>What is wrong with this?</p>