title: PHP MD5 Password Encryption and DB Entry
body: <p>I have built a simple registration form shown below and Iam trying to get the users to have their passwords encrypted and then entered into my database. I am attempting to use md5 encryption. I have also attached the database connection script.</p>
  
  <p>My goal is when I check my database, I want to see the following: ( id, name, username, encrypted password )</p>
  
  <p>The issue I have is that the form does not process completely. All I get this error (Error: Unknown column 'd8578edf8458ce06fbc5bb76a58c5ca4' in 'field list' ).</p>
  
  <p>Could some tell me or show me " What is it that needs to be corrected either in my Code or SQL insert and /or my Variables" to make this work correctly. I know that its probably a very, very simple fix. I am just stuck at this point.</p>
  
  <p>I really appreciate your help.</p>
  
  <pre><code>&lt;?php
  error_reporting(0);
  if($_POST['submit'])
  { //Begining of full IF Statment
  $name = $_POST['name'];
  $username = $_POST['username'];
  $password = $_POST['password'];
  $confirm_password = $_POST['confirm_password'];
  // Encrypt Pasword
  $enc_password = md5($password);
  //$enc_password2 = md5($confirm_password);
  
  
  // Confirm All feild were filled out when submit button was pressed
  if($name &amp;&amp; $username &amp;&amp; $password &amp;&amp; $confirm_password) 
  {
  // Confirm that the NAME that you used is NOT greater than 30 characters     
       if(strlen($name)&gt;24)
       {
       echo "&lt;h2&gt;&lt;center&gt;YOUR NAME IS TOO LONG!!!!&lt;/center&gt;&lt;/h2&gt;&lt;br&gt;";
       }
  // Confirm that the USERNAME that you used is NOT greater than 10 characters        
      if(strlen($username)&gt;10)
       {
       echo "&lt;h2&gt;&lt;center&gt;YOUR USERNAME IS TOO LONG!!!!&lt;/center&gt;&lt;/h2&gt;&lt;br&gt;";
       }
       else {
  
  // Confirm that the PASSWORD that you used MATCH &amp; Between 6 and 15 characters   
          if(strlen($password)&gt;10 || strlen($password)&lt;6)
           {
           echo "&lt;h2&gt;&lt;center&gt;YOUR PASSWORD MUST BE BETWEEN 6 and 15          CHARACTERS!!!!&lt;/center&gt;&lt;/h2&gt;&lt;br&gt;";
           }
          if($password == $confirm_password)
          {
          // Database Connection required
          require "db_conncect.php";
          // We Now connect to the Dabase and insert the Form input details
          //------- ### ENTERING ALL INFORMATION INTO THE DATABASE BELOW ### --------// 
  
  
  // 1. Create a database connection
  $con = mysql_connect("localhost","root",""); // &lt;-- THIS IS WHERE YOU " CAN CHANGE " THE USERNAME IS "root", PASSWORD IS "" ONLY.
  
  if (!$con) {
    die('Database connection failed could not connect: ' . mysql_error());
    }
  
  // 2. Select a database to use
  $db_select = mysql_select_db("registernow_2012",$con); // &lt;-- THE "registernow_2012" IS     THE NAME OF THE DATABASE.
  if (!$db_select) {
    die('Database selection failed could not connect: ' . mysql_error());
  }
  
  mysql_select_db("registernow_2012", $con); // &lt;-- THE "registernow_2012" IS THE NAME OF THE DATABASE TO BE CONNECTED.
  
      // &lt;-- THE `registernow_2012` IS THE NAME OF THE DATABASE TO BE CONNECTED....     `visitors` IS THE TABLE WITH ALL THE FIELDS WITHI IN THE DATABASE.
  
  
  $sql="INSERT INTO `registernow_2012`.`users` (`id` , `name` , `username` ,
  `$enc_password` , `confirm_password`    )
  VALUES (NULL , '$_POST[name]', '$_POST[username]', '[$enc_password]', '$_POST[confirm_password]')";
  
  
  if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
  }
  
  // 3. Close Connection
  mysql_close($con);
  
  header("Location: index.php");  // &lt;-- THIS IS WHERE YOU CAN CHANGE THE "Location: Thank you / Index page" of the THANK YOU PAGE.       
  
          }
      else 
      {
      echo "&lt;h2&gt;&lt;center&gt;PASSWORDS MUST MATCH!!!!!&lt;/center&gt;&lt;/h2&gt;&lt;br&gt;";
      }   
  
       }
  
      //echo "&lt;h2&gt;&lt;center&gt;WORKING!!!!&lt;/center&gt;&lt;/h2&gt;";
  }   
  else echo "&lt;h2&gt;&lt;center&gt;ALL FEILDS MUST BE COMPLETED&lt;/center&gt;&lt;/h2&gt;";
  
  } //Ending of full IF Statment
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang='en'&gt;
      &lt;head&gt;
          &lt;title&gt;THE FORM MY WAY NOW&lt;/title&gt;
      &lt;/head&gt;
  &lt;body&gt;
  &lt;div id='centerstage'&gt;
      &lt;form name="myform" action="workingitoutproperly.php" method="POST"&gt;
        &lt;p&gt;
          &lt;label&gt;Name&lt;/label&gt;&lt;br&gt;
          &lt;input type='text' name='name' value=''&gt;&lt;br&gt;
          &lt;label&gt;UserName&lt;/label&gt;&lt;br&gt;
          &lt;input type='text' name='username' value=''&gt;&lt;br&gt;
          &lt;label&gt;Password&lt;/label&gt;&lt;br&gt;
          &lt;input type='password' name='password' value=''&gt;&lt;br&gt;
          &lt;label&gt;Re-Enter Password&lt;/label&gt;&lt;br&gt;
          &lt;input type='password' name='confirm_password' value=''&gt;&lt;br&gt;
          &lt;br&gt;
          &lt;input type='submit' name='submit' value='REGISTER NOW!!'&gt;
      &lt;/p&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>