Jquery validation for email exist in laravel

Viewed 1728

I need to validate email id for weather its already exist or not

i have tried this code but it is not working and in inspect element it showing:

jquery-1.10.2.js:8706

POST http://localhost/selfcomply/public/admin/companymaster/check_email.php 405 (Method Not Allowed) and

MethodNotAllowedHttpException in RouteCollection.php line 218:

validation.js file

$("#companydata").validate
({
    rules: {
        company_email:{
            required: true,
            emailer: true,
            remote:{
                url:"check_email.php",
                type:"post"
            }
                },

    messages:{

        company_email:{
            required: "Please enter the email address  ",
            remote:"Already Exist"
        },

    }
});

check_email.php

  $email = "'".$_POST["emails"]."'";
  $showmember = DB::select( DB::raw("SELECT count(company_email) as countemail FROM tbl_company_master WHERE company_email = ".$email.""));
  if($showmember[0]->countemail > 0)
  {
      return "false";
  }
  else
  {
    return "true";
  }

weather i need to give path in route.php or not, but i dont think so

2 Answers
Related