title: Confirm password field
body: <p>I am trying to confirm my password field before the users details are sent to the server. I have tried to implement this using jquery and php but I can't get it working. I know this should be fairly simple, but it is sending the details without confirming the password. </p>
  
  <p>My code is as follows(I have removed some divs, to make it clear)</p>
  
  <pre><code>  &lt;form onSubmit="return validate()" id="register" method="post" action="../script/sendUserDetails.php"&gt;
      &lt;p style=" font-size:1.8em; color:black;"&gt;Ready&lt;/p&gt;
      &lt;p style=" font-size:1.4em; color:black;"&gt;Enter your details&lt;/p&gt;
  
          &lt;label for="fname"&gt;First Name:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input autofocus name="fname" type="text" id="fname" 
           class="textEntry" required placeholder="First Name"/&gt;&lt;br /&gt;
          &lt;label for="lname"&gt;Last Name:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="lname" type="text" id="lname" class="textEntry" required placeholder="Last Name"/&gt;&lt;br /&gt;
             &lt;label for="email"&gt;Email:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="email" type="email" id="emailR" class="textEntry" required placeholder="Email"/&gt;&lt;br /&gt;
  
     &lt;p style="font-size:1.8em; color:black;"&gt;Steady&lt;/p&gt;
      &lt;p style="font-size:1.4em; color:black;"&gt;And your address&lt;/p&gt;
          &lt;label for="address1"&gt;Address1:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="address1" type="text" id="address1" class="textEntry" required placeholder="Address"/&gt;&lt;br /&gt;
          &lt;label for="address2"&gt;Address2:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="address2" type="text" id="address2" class="textEntry" placeholder="Address" /&gt;&lt;br /&gt;
          &lt;label for="town"&gt;Town:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="town" type="text" id="town" class="textEntry" required placeholder="Town"/&gt;&lt;br /&gt;
          &lt;label for="postcode"&gt;Post Code:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="postcode" type="text" id="postcode" class="textEntry" required placeholder="Post Code"/&gt;
          &lt;br /&gt;
      &lt;label for="phone"&gt;Phone:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="phone" placeholder="Phone" type="text" id="phone" class="textEntry" required/&gt;&lt;br /&gt;
  
  &lt;p style="font-size:1.8em; color:black;"&gt;Go&lt;/p&gt;
      &lt;p style="font-size:1.4em; color:black; "&gt;Now a password&lt;/p&gt;
  
           &lt;label for="password"&gt;Password:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="password" placeholder="Password" type="password" id="passwordR" class="passwordEntry" 
            required/&gt;&lt;br /&gt;
           &lt;label for="confirm_password"&gt;Confirm Password:&amp;nbsp;&lt;/label&gt;&lt;br/&gt;
          &lt;input name="confirm_password" placeholder="Password" type="password" id="confirm_password" class="passwordEntry" 
            required/&gt;&lt;br /&gt;
  
          &lt;p &gt;&lt;input class="button-link" type="submit" id="cu" value="Create Account"/&gt;&lt;/p&gt;
         &lt;/form&gt;  
  </code></pre>
  
  <p>My php code is;</p>
  
  <pre><code>&lt;?php
   include("dbconnect.php");
   $fname=$_POST['fname'];
   $lname=$_POST['lname'];
   $address1=$_POST['address1'];
   $address2=$_POST['address2'];
   $town=$_POST['town'];
   $postcode=$_POST['postcode'];
   $phone=$_POST['phone'];
   $email=$_POST['email'];
   $password=$_POST['password'];
   $query = "select email from members where email='$email'";
   $link = mysql_query($query);
   if (!$link) {
    die('query error');
   }
   $num=mysql_num_rows($link);
   if ($num&gt;0){
    die('email already exists'); //email already taken
   }
   $query = "insert into members (fname, lname, address1, address2, town, postcode, phone, email,  
     password) values('$fname','$lname','$address1','$address2','$town','$postcode','$phone',
     '$email','$password')";
   $link = @ mysql_query($query);
   if (!$link) {
    die('table write error');
   }
   header("location:../members/members.master.php?page=regconfirm.php");
  ?&gt;
  </code></pre>
  
  <p>and the jquery code I tried to use(from this site);</p>
  
  <pre><code>function validate(){
  
      if(!document.getElementById("Password").value==document.getElementById("confirm_password").value)alert("Passwords do no match");
      return document.getElementById("Password").value==document.getElementById("confirm_password").value;
     return false;
      }
  </code></pre>
  
  <p>thanks for any help.</p>