title: call to a member function bind_param() on a non-object mysqli
body: <p>I am getting this error when I submit the form. 
  call to a member function bind_param() on a non-object
  I have checked the console as well. It shows all the values I enter in the form. The values are getting stored in json variable and passed to the php page.It is on the bind_param() function, it shows the error. The same code works for the remaining 2 pages of my project, but it is not working for this one. Please help</p>
  
  <p>Here is the PHP code</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "kites";
  // Create connection
  $conn = mysqli_connect($servername, $username, $password, $dbname);
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_connect_error());
      alert("Connection failed");
  }
  else
  {
  // Check for empty fields
    if(
          empty($_POST['username']) || empty($_POST['password']) || empty($_POST['firstname']) || empty($_POST['lastname']) || empty($_POST['age']) || empty($_POST['contact']) || empty($_POST['streetname']) || empty($_POST['buildingname']) || empty($_POST['landmark']) || empty($_POST['area']) || empty($_POST['pincode']) || empty($_POST['email']) || empty($_POST['univ']) || empty($_POST['qualification']) || empty($_POST['dialcode']) || empty($_POST['countrycode']) || empty($_POST['bloodgroup']) || empty($_POST['school'])  
       )
    {  
    echo json_encode(array('status'=&gt;false,'msg'=&gt;'No arguments provided'));
    }
    else if(is_numeric($_POST['firstname']) &amp;&amp; is_numeric($_POST['lastname']))
    {
      echo json_encode(array('status'=&gt;false,'msg'=&gt;'Name should not contain numbers. Please try again'));
    }
    else if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
    {
      echo json_encode(array('status'=&gt;false,'msg'=&gt;'Check your email id and try again'));
    }
    else if(!is_numeric($_POST['age']))
    {
      echo json_encode(array('status'=&gt;false,'msg'=&gt;'Age should contain only numbers'));
    }
  
    else{
           $username = $_POST['username'];
           $password = $_POST['password'];
           $firstname = $_POST['firstname'];
           $lastname = $_POST['lastname'];
           $age = $_POST['age'];
           $bloodgroup = $_POST['bloodgroup'];
           $contact = $_POST['contact'];
           $streetname = $_POST['streetname'];
           $buildingname = $_POST['buildingname'];
           $landmark = $_POST['landmark'];
           $area = $_POST['area'];
           $pincode = $_POST['pincode'];
           $email = $_POST['email'];
           $univ = $_POST['univ'];
           $school = $_POST['school'];
           $qualification = $_POST['qualification'];
           $dialcode = $_POST['dialcode'];
           $countrycode = $_POST['countrycode'];
          // $sql = "INSERT INTO join_form (name,email,contact,role,dialcode,countrycode) VALUES ('$name','$email','$contact','$role','$dialcode','$countrycode')";
           $stmt = $conn-&gt;prepare("INSERT INTO register_form(username,password,firstname,lastname,age,bloodgroup,contact,streetname,buildingname,landmark,area,pincode,email,univ,school,qualification,dialcode,countrycode) VALUES(?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?)");
          $stmt-&gt;bind_param("ssssisssssssssssss",$username,$password,$firstname,$lastname,$age,$bloodgroup,$contact,$streetname,$buildingname,$landmark,$area,$pincode,$email,$univ,$school,$qualification,$dialcode,$countrycode);
          $sql = $stmt-&gt;execute();
          if ($sql) {
            echo json_encode(array('status'=&gt;true,'msg'=&gt;"New record created successfully"));
         //   // Create the email and send the message
         // $to = 'naitikgada1995@gmail.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
         // $email_subject = "Registration Successfull:  $name";
         // $email_body = "We have sent this mail to inform you that your registration is successfull\n\n"
         //                ."Here are the details:\n\n"
         //                ."Name: $name\n\nEmail: $email\n\nContact:$contact\n\nPassword: $password\n\n";
         // $headers = "From: noreply@kiddo.com\n";
         // $headers .= "Reply-To: $email";  
         // mail($to,$email_subject,$email_body,$headers);
         // // $response['status'] = 'true';
          } 
          else {    
            echo json_encode(array('status'=&gt;false,'msg'=&gt;'Enter different email id or contact number and try again'));
          // return false;
          // $response['feedback'] = 'false';
          // $response['message'] = 'Sorry, something went wrong. Please try again. Try entering a different email id and contact number';
          // echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn);
        }
      // header("Content-Type: application/json; charset=utf-8", true);
  
  
    }
  }     
  ?&gt;
  </code></pre>