php - Insert data into database after jQuery validation. Button only works for validation -


i insert data database after jquery validation. however, submit button works validation , won't submit data. please me thanks~


this form

<form id="myform"  method="post"> <label for="username">username: </label> <input type="text" class="left" id="username" name="username"> <label for="name">name: </label> <input type="text" class="left" id="name" name="name"> <label for="password">password </label> <input type="password" class="left" id="password" name="password"> <label for="repassword">password </label> <input type="password" class="left" id="repassword" name="repassword"> <label for="email">email </label> <input type="email" class="left" id="email" name="email"> <label for="contact">contact</label> <input type="text" class="contact" id="contact" name="contact"> <input id="submit" type="submit" name="submit" value="send" />   </form> 

this jquery validation form

<script> $.validator.addmethod('contact', function (value, element) {     return this.optional(element) || /^\d{3}-\d{7}$/.test(value); }, "please enter valid phone number");  jquery.validator.addmethod( 'passwordmatch', function(value, element) {      // 2 password inputs     var password = $("#password").val();     var confirmpassword = $("#repassword").val();      // check equality password inputs     if (password != confirmpassword ) {         return false;     } else {         return true;     } }, "your passwords must match");  $(document).ready(function() { $( "#myform" ).validate({   rules: {       debug:false,       username: {       required: true,       rangelength:[4,10],       // remote: "user_check2.php"     },      name: {       required: true,       rangelength:[4,10]     },      password: {       required: true,       rangelength:[6,10]     },      repassword: {     passwordmatch: true // set on field you're trying match     },      email: {      required: true,     },      contact: {      required: true,     },   },     messages: {     username: {       //remote:"username existed",       required:"enter username",     },        name: {       required:"please enter name",     },      password: {       required:"please enter password",       rangelength:"you must contain 6 10 character"     },      contact: {      required:"please enter phone number",   },            }); });  </script> 

the last step insert data table in database. submit button not work.

<?php      if(isset($_post['submit']))     {             $adminusername = $_post["username"];         $name = $_post["name"];         $email = $_post["email"];         $phone = $_post["contact"];         $password = $_post["password"];         //$query = "select * admin admin_username = '$adminusername'";         //$result = mysqli_query($conn,$query);         //$rowcount = mysqli_num_rows($result);         mysqli_query($conn,"insert admin(admin_username,admin_name,admin_email,admin_contact,admin_password) values               ('$adminusername','$name','$email','$phone','$password')");         mysqli_close($conn);         } ?> 

i think miss action attribute in form.

<form method="post" action="your_php_code.php"> 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -